Thomas, I'm pretty sure that all you need to do is treat it just like a 1:m without a collection. I've got several examples that look something like this:
<class name="test.A" identity="id"> <description>Document Text</description> <map-to table="TAB_A" xml="A"/> <field name="id" type="integer"> <sql name="id" type="integer"/> </field> <field name="b" type="test.B" required="true"> <sql-many key name="a_id"/> </field> </class> <class name="test.B" identity="id"> <description>Document Text</description> <map-to table=".TAB_B" xml="B"/> <field name="id" type="integer"> <sql name="id" type="integer"/> </field> <field name="a" type="test.A"> <sql name="a_id"/> </field> </class> In my case, B also depends on A, since B can't exist without A. Hope this helps - Margaret -----Original Message----- From: Thomas Olausson [mailto:[EMAIL PROTECTED]] Sent: Monday, October 07, 2002 5:00 AM To: [EMAIL PROTECTED] Subject: [castor-dev] one-to-one relationship I haven't found this scenario in the examples, even if it's very simple: [I have vectors and collections working just fine, but not this one] Class A has one reference to B, as a one-to-one relationship. This maps to these two tables: Table A (id) Table B (id,a_id) a_id is a foreign key to A.id When I load class A, I want castor to load the corresponding class B (if any), just like in a collection, but in this case, there's only one reference. So, I need a field-declaration to B in A. The following example almost works, but B never gets loaded when I load A. I think the second field-declaration is wrong somehow. <class name="test.A" identity="id"> <description>Document Text</description> <map-to table="TAB_A" xml="A"/> <field name="id" type="integer"> <sql name="id" type="integer"/> </field> <field name="b" type="test.B" required="true"> <sql name="id"/> </field> </class> <class name="test.B" identity="id"> <description>Document Text</description> <map-to table=".TAB_B" xml="B"/> <field name="id" type="integer"> <sql name="id" type="integer"/> </field> <field name="a" type="test.A"> <sql name="a_id"/> </field> </class> B doesn't have to have a reference to A, but I've tried to add this to see any different behavior. Regards /Thomas ----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to [EMAIL PROTECTED] with a subject of: unsubscribe castor-dev ----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to [EMAIL PROTECTED] with a subject of: unsubscribe castor-dev