Yep I agree. It would seem sensible to include this valid (although little used in practice) OO relation.
I only yesterday discovered the "PersistentFieldClass" setting, and realised that as I am using "PersistentFieldDirectAccessImpl", I can just use a collection descriptor, and in my bean: private List mes; public getMe(){ if (mes!=null && mes.size()>0){ return (Emp)mes.get(0); } else { return null; } } Daniel. -----Original Message----- From: Stefan Schlosser [mailto:[EMAIL PROTECTED] Sent: 04 May 2004 15:06 To: OJB Users List Subject: Re: 1:1 bi-directional reference Hi, Me too ! I'd like to add that if you model it with 2 fk's you'll get into a nice update problem. How do you ensure that the to fk's are consistent ? You'll have to program something manually. Since I use a generic access to my value object the solution with the one-element-list doesn't quite cut it for me .. I'd quite like to see an inverse-foreign-key in a relation descriptor. Any chance this is upcoming ? Cheers, Stefan Daniel Perry wrote: > I cant seem to figure out bi-directional references. Am I being thick? or do > they not exist? > > I have two objects in a database, which need to be associated with each > other (optionally). > > ClassB has a property "ClassA me", and "int meId". > > "meId" is mapped as an int, and "me" is mapped as a reference descriptor > with "meId" as a foreign key. So, ClassB -> ClassA works. > > I've tried mapping "ClassA.Me" as a reference descriptor of type "ClassB" > with an inverse-foreign-key, exactly as for collection descriptors but that > doesn't work. > > How can I do this? As far as I can tell I have a choice: > 1. have two separate relations - with foreign keys in both tables. > 2. have one direction as a reference and the other direction as a > collection. > > Both of these seem like madness to me, although I guess I can bodge the > second so as to make the collection hidden, and just have a getter for a > non-existent property. > > Daniel. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]