Re: [ojb-users] Problems with Foreign-Key
Brought to you by:
thma
From: Thomas M. <tho...@ho...> - 2002-05-31 09:16:48
|
Hi Joerg, Mhh, this is a starange behaviour, as there are testcase, that prrof that automatic assignment works. Also, your mapping seems OK! You could try the following: set <autoincrement>true</autoincrement> in the mapping of the primary key of EObject. before storing your eObject, just compute its Identity by Identity oid = new Identity(eObject); now eObjects primary is set! than store eObject. I hope this will solve your problem, Thomas Jörg Benne wrote: > 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 > > > > _______________________________________________________________ > > Don't miss the 2002 Sprint PCS Application Developer's Conference > August 25-28 in Las Vegas -- http://devcon.sprintpcs.com/adp/index.cfm > > _______________________________________________ > Objectbridge-users mailing list > Obj...@li... > https://lists.sourceforge.net/lists/listinfo/objectbridge-users > > > > |