[ojb-users] Problems with Foreign-Key
Brought to you by:
thma
From: <jo...@ga...> - 2002-05-30 20:15:49
|
Hi, I have a quite simple problem: My Sample has two Classes, eObject and attribute, with one eObject having several attributes and 1 attribute belong to one eObject. The Mapping... <ClassDescriptor id="1"> <class.name>com.eobjects.EObject</class.name> <table.name>eobject</table.name> <FieldDescriptor id="1"> <field.name>ID</field.name> <column.name>ID</column.name> <jdbc_type>INTEGER</jdbc_type> <PrimaryKey>true</PrimaryKey> </FieldDescriptor> ... <CollectionDescriptor id="1"> <cdfield.name>attributes</cdfield.name> <items.class>com.eobjects.Attribute</items.class> <inverse_fk_descriptor_ids>5</inverse_fk_descriptor_ids> <auto.update>true</auto.update> </CollectionDescriptor> </ClassDescriptor> <ClassDescriptor id="2"> <class.name>com.eobjects.Attribute</class.name> <table.name>attribute</table.name> <FieldDescriptor id="1"> <field.name>ID</field.name> <column.name>ID</column.name> <jdbc_type>INTEGER</jdbc_type> <PrimaryKey>true</PrimaryKey> </FieldDescriptor> ... <FieldDescriptor id="5"> <field.name>eObjectID</field.name> <column.name>objID</column.name> <jdbc_type>INTEGER</jdbc_type> </FieldDescriptor> <ReferenceDescriptor id="1"> <rdfield.name>eObject</rdfield.name> <referenced.class>com.eobjects.EObject</referenced.class> <fk_descriptor_ids>5</fk_descriptor_ids> </ReferenceDescriptor> </ClassDescriptor> When I create an eObject and set it's attributes Vector and store it (I just call broker.store(eObject), the ID is given by Database (OJB sends a select to get it)) ), both eObject and attributes are saved, BUT the Value ob objID in Table Attribute is 0 althought the eObject it belongs to has received the ID 2. So I can't find my attributes when I reload my eObject. But I can't set the foreign-key by myself, as I don't know it until a new eObject is saved for the first time. What's wrong? Joerg |