The workaround I have had to use is to create my JavaBean accessors such as this:
List item;
public Item getItem() {
return item.get(0);
}
public void setItem(Item item) {
item.set(0, item);
}
This still gives me type checking on the object and allows the FK to be on either
entity on a 1-1 reference.
BTW...I would like to see this added to the TODO list. A FK on a 1-1 relation should
be allowed on either entity in the database. This requires both of these forms to be
valid:
<class-descriptor class="Foo" table="foo" >
...
<reference-descriptor name="bar" class-ref="Bar">
<foreignkey field-ref="barID" />
</reference-descriptor>
...
</class-descriptor>
And
<class-descriptor class="Foo" table="foo" >
...
<reference-descriptor name="bar" class-ref="Bar">
<inverse-foreignkey field-ref="fooID" />
</reference-descriptor>
...
</class-descriptor>
Thoughts?
Wally
-----Original Message-----
From: Stefan Schl�sser [mailto:[EMAIL PROTECTED]
Sent: Thursday, April 29, 2004 5:49 AM
To: OJB Users List
Subject: 1-1 Relationship with single FK ??
Hi,
I would like to model a one-to-one Relationship between 2 classes.
For simplicity I would like to have a single FK in one of the classes
only. Unfortunately OJB does not allow the definition of an
"inverse-foreign-key" within the reference descriptor.
How do I solve this ? I don't wish to have a List in one of the classes,
I prefer the type-safe using a single Object.
If I had 2 fk's what happens upon update on one of the objects ? Which
setting do I need to take to ensure consistency of both fks? I.e. update
only the other classes fk but leave other fields untouched?
Thanks for any help on this, by the way I am using CVS head.
Cheers
S.Schl�sser
---------------------------------------------------------------------
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]