Re: 1:n mapping
Hi Kumar, You can insert the parent and the child together by setting the auto-update=true in the repository_user.xmland if you want to do insert separately parent and childs you put it to false class-descriptor class=parent table=PARENT field-descriptor name=id primarykey=true autoincrement=true column=ID sequence-name=parentid_seq jdbc-type=INTEGER/ field-descriptor name=name column=NAME jdbc-type=VARCHAR/ collection-descriptor name=childs element-class-ref=Child auto-delete=false auto-update=false inverse-foreignkey field-ref=parentid/ /collection-descriptor /class-descriptor - Original Message - From: Kumar Chandran [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, August 04, 2004 12:56 AM Subject: 1:n mapping Hi, Is it possible to insert both parent and children (1:n) at the same time or do we have to insert each child record individually after inserting the parent record. If this can be done some help is appreciated in this regard as to how to configure it in repository_user.xml and how to use odmg api to do this. Thanks, Kumar Chandran This electronic message contains information from CTIS, Inc., which may be company sensitive, proprietary, privileged or otherwise protected from disclosure. The information is intended to be used solely by the recipients named above. If you are not an intended recipient, be aware that any review,disclosure, copying, distribution or use of this transmission or its contents is prohibited. If you have received this transmission in error, please notify us immediately at [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: 1:n Mapping
Hi Norbert, I assume that the attribute you want to treat as a primary key is a candidate key. Therefore, you can declare it as a primary key in the repository even if it is not a PK in the database. OJB always resolves FK for a collection descriptor against the declared primary key. Hope this helps, Wally -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Tuesday, December 02, 2003 7:02 AM To: [EMAIL PROTECTED] Subject: 1:n Mapping Hello, we need a 1:n mapping where the joining attribute of the parent class is not its primary key. Example: class-descriptor class=at.gv.bmi.ClassA table=TableA field-descriptor name=fieldA column=A jdbc-type=CHAR primarykey=true / field-descriptor name=fieldB column=B jdbc-type=CHAR / collection-descriptor name=joinAB element-class-ref=at.gv.bmi.ClassB inverse-foreignkey field-ref=fieldY/ /collection-descriptor /class-descriptor class-descriptor class=at.gv.bmi.ClassB table=TableB field-descriptor name=fieldX column=X jdbc-type=CHAR primarykey=true / field-descriptor name=fieldY column=Y jdbc-type=CHAR / field-descriptor name=fieldZ column=Z jdbc-type=CHAR / /class-descriptor The join has to be made from ClassA:B to ClassB:Y, ie the where condition has to be where A0.B = A1.Y instead of A0.A = A1.Y (does ojb uses A0.A because its the pk?). What do we have to do to get this join? Thanks for help, Norbert. - 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]
RE: 1:n Mapping
Hi Wally, thanks for your answer first of all. I already was afraid to hear that. Why does this limitation exist? I don't see the point for this unbreakable, implicit commitment. It might be right that in many cases a need of this points out a lack in the database design, but not necessarily. As I understood there is no way to have several primary keys (not compound), right? Is there a way to get around this using a query-customizer? Is there a way/chance to introduce another element inside the collection descriptor to declare the referenced field explicitly? One more answer to my questions would help me a lot. Thanks, Norbert. -Original Message- From: Gelhar, Wallace Joseph [mailto:[EMAIL PROTECTED] Sent: Dienstag, 02. Dezember 2003 15:31 To: OJB Users List Subject: RE: 1:n Mapping Hi Norbert, I assume that the attribute you want to treat as a primary key is a candidate key. Therefore, you can declare it as a primary key in the repository even if it is not a PK in the database. OJB always resolves FK for a collection descriptor against the declared primary key. Hope this helps, Wally -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Tuesday, December 02, 2003 7:02 AM To: [EMAIL PROTECTED] Subject: 1:n Mapping Hello, we need a 1:n mapping where the joining attribute of the parent class is not its primary key. Example: class-descriptor class=at.gv.bmi.ClassA table=TableA field-descriptor name=fieldA column=A jdbc-type=CHAR primarykey=true / field-descriptor name=fieldB column=B jdbc-type=CHAR / collection-descriptor name=joinAB element-class-ref=at.gv.bmi.ClassB inverse-foreignkey field-ref=fieldY/ /collection-descriptor /class-descriptor class-descriptor class=at.gv.bmi.ClassB table=TableB field-descriptor name=fieldX column=X jdbc-type=CHAR primarykey=true / field-descriptor name=fieldY column=Y jdbc-type=CHAR / field-descriptor name=fieldZ column=Z jdbc-type=CHAR / /class-descriptor The join has to be made from ClassA:B to ClassB:Y, ie the where condition has to be where A0.B = A1.Y instead of A0.A = A1.Y (does ojb uses A0.A because its the pk?). What do we have to do to get this join? Thanks for help, Norbert. - 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]
Re: 1:n Mapping problem with Map
Hi, [DEFAULT] WARN: org.apache.ojb.broker.metadata.ClassDescriptor: Could not found autoincrement attribute for class: org.apache.ojb.odmg.collections.DMapImpl Do you really use the shipped repository_internal.xml file? The warning says that there is no autoincrement field declared. Do you mixed up different versions of OJB? class-descriptor class=org.apache.ojb.odmg.collections.DListImpl table=OJB_DLIST field-descriptor name=id column=ID jdbc-type=INTEGER primarykey=true autoincrement=true= !!! / . regards, Armin - Original Message - From: ludovic.bert [EMAIL PROTECTED] To: ojb-user [EMAIL PROTECTED] Sent: Wednesday, July 02, 2003 9:25 AM Subject: 1:n Mapping problem with Map Hello all, I want to have a 1:n mapping with a HashMap, but i have the following problem: - Firstly i defined my classes like this: public class Client { protected Long id = null; protected String nom = ; protected HashMap contacts = null; public Client() { super(); this.contacts = new HashMap(); } // getters and setters. } public class Contact { private Long id = null; private long codeClient = 0; private String code = ; private String nom = ; private String titre = ; private String telephone = ; private String fax = ; private String eMail = ; private String service = ; private String unite = ; public Contact() { super(); } // getters and setters } - Secondly i defined the OJB mapping like this: !-- Definitions for com.mps.safari.commun.Client -- class-descriptor class=com.mps.safari.commun.Client table=client field-descriptor id=1 name=id column=CLIENT_ID jdbc-type=BIGINT primarykey=true autoincrement=true/ field-descriptor id=2 name=nom column=NOM jdbc-type=VARCHAR/ collection-descriptor name=contacts collection-class=org.apache.ojb.odmg.collections.DMapImpl element-class- ref=com.mps.safari.commun.Contact auto-update=true auto-delete=true inverse-foreignkey field-ref=codeClient/ /collection-descriptor /class-descriptor !-- Definitions for com.mps.safari.commun.Contact -- class-descriptor class=com.mps.safari.commun.Contact table=contact field-descriptor id=1 name=id column=CONTACT_ID jdbc-type=BIGINT primarykey=true autoincrement=true/ field-descriptor id=2 name=codeSociete column=CODE_SOCIETE jdbc-type=BIGINT/ field-descriptor id=3 name=codeClient column=CODE_CLIENT jdbc-type=BIGINT/ field-descriptor id=4 name=code column=CODE jdbc-type=VARCHAR/ field-descriptor id=5 name=nom column=NOM jdbc-type=VARCHAR/ field-descriptor id=6 name=titre column=TITRE jdbc-type=VARCHAR/ field-descriptor id=7 name=telephone column=TELEPHONE jdbc-type=VARCHAR/ field-descriptor id=8 name=fax column=FAX jdbc-type=VARCHAR/ field-descriptor id=9 name=eMail column=EMAIL jdbc-type=VARCHAR/ field-descriptor id=10 name=service column=SERVICE jdbc-type=VARCHAR/ field-descriptor id=11 name=unite column=UNITE jdbc-type=VARCHAR/ /class-descriptor - Finally when i get a Client i have the following error message : [DEFAULT] WARN: org.apache.ojb.broker.metadata.ClassDescriptor: Could not found autoincrement attribute for class: org.apache.ojb.odmg.collections.DMapImpl [DEFAULT] ERROR: DMapImpl: Generation of new id failed null java.lang.NullPointerException at org.apache.ojb.broker.util.sequence.AbstractSequenceManager.getUniqueVal ue(Unknown Source) at org.apache.ojb.odmg.collections.DMapImpl.generateNewId(Unknown Source) at org.apache.ojb.odmg.collections.DMapImpl.init(Unknown Source) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorA ccessorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingCons tructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:274) at java.lang.Class.newInstance0(Class.java:296) at java.lang.Class.newInstance(Class.java:249) at org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getCollectionByQuer y(Unknown Source) at org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getCollectionByQuer y(Unknown Source) at org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.retrieveCollection( Unknown Source) at org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.retrieveCollections (Unknown Source) at org.apache.ojb.broker.accesslayer.RsIterator.getObjectFromResultSet(Unkn own Source) at org.apache.ojb.broker.accesslayer.RsIterator.next(Unknown Source) at org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getCollectionByQuer y(Unknown Source) at org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getCollectionByQuer y(Unknown Source) at org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getCollectionByQuer y(Unknown Source) at org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getCollectionByQuer y(Unknown Source) at
Re: 1:n mapping
hi scott, check BrokerHelper#getKeyValues() jakob Weaver, Scott wrote: Yup, that was it. FieldConversions break backreferences. Verfied in both ODMG and PB. Any idea how I can fix that or were I can look. *===* * Scott T Weaver* * Jakarta Jetspeed Portal Project * * [EMAIL PROTECTED] * *===* -Original Message- From: Mahler Thomas [mailto:[EMAIL PROTECTED] Sent: Monday, June 30, 2003 12:28 PM To: 'OJB Users List' Subject: RE: 1:n mapping Hi again, FieldConversions could be a factor. We have testcases for FieldConversions on PrimaryKey fields, but I think no tests for 1:n plus backreference + FieldConversion on foreignkey. Can you modify your setup to test without fieldconversion? cheers, thomas -Original Message- From: Weaver, Scott [mailto:[EMAIL PROTECTED] Sent: Monday, June 30, 2003 6:29 PM To: 'OJB Users List' Subject: RE: 1:n mapping Hi Thomas, The test case runs fine, but my implementation is still failing using both ODMG and PB with auto-update/auto-retrieve set to true. I am using field conversions in my PK and FK fields. Could that be a factor? *===* * Scott T Weaver* * Jakarta Jetspeed Portal Project * * [EMAIL PROTECTED] * *===* -Original Message- From: Mahler Thomas [mailto:[EMAIL PROTECTED] Sent: Monday, June 30, 2003 10:11 AM To: 'OJB Users List' Subject: RE: 1:n mapping Hi all, Mhh, strange. There is a testcase o.a.ojb.broker.AutomaticForeignKeys that explicitely tests the assignement of foreign keys for such a 1:n association. /** test automatic assignment of foreign keys for 1:n reference. */ public void testOneManyReference() { try { Article art1 = new Article(); art1.setArticleName(TOPLink); Article art2 = new Article(); art2.setArticleName(OJB); Article art3 = new Article(); art3.setArticleName(CASTOR); ProductGroup pg = new ProductGroup(); pg.setName(O/R mapping tools); pg.add(art1); pg.add(art2); pg.add(art3); Identity pgOID = new Identity(pg, broker); broker.store(pg); broker.clearCache(); InterfaceProductGroup readInPG = (InterfaceProductGroup) broker.getObjectByIdentity(pgOID); assertEquals(pg.getName(), readInPG.getName()); assertEquals(pg.getAllArticles().size(), readInPG.getAllArticles().size()); InterfaceArticle art1a = (InterfaceArticle) pg.getAllArticles().get(0); InterfaceArticle art2a = (InterfaceArticle) pg.getAllArticles().get(1); InterfaceArticle art3a = (InterfaceArticle) pg.getAllArticles().get(2); assertEquals(art1.getArticleName(), art1a.getArticleName()); assertEquals(art2.getArticleName(), art2a.getArticleName()); assertEquals(art3.getArticleName(), art3a.getArticleName()); } catch (Throwable t) { System.out.println(t.getMessage()); t.printStackTrace(); fail(t.getMessage()); } } Article has a backreference to Productgroup. this testcase passes, so I have no idea what could be wrong here... cheers, Thomas -Original Message- From: Weaver, Scott [mailto:[EMAIL PROTECTED] Sent: Monday, June 30, 2003 4:08 PM To: 'OJB Users List' Subject: RE: 1:n mapping I have been having the same issue with 1:n mappings were n's FK is not getting updated if n has a reference-descriptor back to 1. *===* * Scott T Weaver* * Jakarta Jetspeed Portal Project * * [EMAIL PROTECTED] * *===* -Original Message- From: Timofey Korolev [mailto:[EMAIL PROTECTED] Sent: Monday, June 30, 2003 9:11 AM To: OJB Users List Subject: RE: 1:n mapping On Mon, 2003-06-30 at 17:08, Mahler Thomas wrote: When i'm saying in my application broker.strore(General) OJB doesn't makes any records in PARTICLE table. Ahh! That's easy: WoW! That worked but partially ;-) select * from PARTICLE looks like id | name | gid +--+- 3 | AAA | 4 | BBB | but the gid column is empty. And it has to reference GENERAL
RE: 1:n mapping
Hope this helps, I am assuming that the problem is the Repository.xml file Class def agreement 1:M collection-descriptor name=roles element-class-ref=sd.specAct.Role inverse-foreignkey field-ref=contextID/ - points to Agreement ID query-customizer /collection-descriptor N:M With Intersection Table collection-descriptor name=composites element-class-ref=sd.prodAgr.Agreement auto-retrieve=true auto-update=true indirection-table=agreement_rel fk-pointing-to-this-class column=componentID/ fk-pointing-to-element-class column=compositeID/ /collection-descriptor -Original Message- From: Timofey Korolev [mailto:[EMAIL PROTECTED] Sent: Monday, June 30, 2003 7:58 AM To: OJB Users List Subject: 1:n mapping Hello! Does anyone has any simple example of 1:n mapping that really works? I'm struggling with this mapping for 3 days and nothing works except 1:1 mapping. -- Regards, CEO Linux-Online.Ru Korolyov Timofey www.linuxshop.ru :: www.prefnews.ru :: www.dotstyle.ru JabberID: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: 1:n mapping
On Mon, 2003-06-30 at 16:17, Jim Shingler wrote: Hope this helps, I am assuming that the problem is the Repository.xml file Thank you Jim, i appreciate your help, but this is not what i need. I'll try to be more specific. I got two classes: class General { private Collection particles; private int id; private String title; } and class Particle { private int particalId; private String name; private int generalId; private General generalObject; } I'm trying to do following mapping class-descriptor class=General table=GENERAL field-descriptor name=id column=id sequence-name=general_id_seq jdbc-type=NUMERIC autoincrement=true primarykey=true / field-descriptor name=title column=title jdbc-type=VARCHAR/ collection-descriptor name=particles element-class-ref=Particle orderby=particleId sort=DESC inverse-foreignkey field-ref=generalId/ /collection-descriptor /class-descriptor class-descriptor class=Particle table=PARTICLE field-descriptor name=particleId column=id jdbc-type=NUMERIC autoincrement=true primarykey=true sequence-name=particle_id_seq / field-descriptor name=name column=name jdbc-type=VARCHAR/ field-descriptor name=generalId column=gid jdbc-type=NUMERIC/ reference-descriptor name=generalObject class-ref=General auto-retrieve=true auto-update=true auto-delete=true foreignkey field-ref=generalId/ /reference-descriptor /class-descriptor I've made this mapping looking on the Advanced O/R Tutorial om OJB's site. And this thing doesn't work. I am at a loss. I want to use it in my phd work, but this problem makes me sick. I think that ojb can save a lot of my coding time... -- Regards, CEO Linux-Online.Ru Korolyov Timofey www.linuxshop.ru :: www.prefnews.ru :: www.dotstyle.ru JabberID: [EMAIL PROTECTED] signature.asc Description: This is a digitally signed message part
RE: 1:n mapping
On Mon, 2003-06-30 at 16:54, Eric Northam wrote: What type of problem are you having? When i'm saying in my application broker.strore(General) OJB doesn't makes any records in PARTICLE table. If you're using OTM, ODMG, or JDO, you need to set auto-update to false. I just have done that - nothing changed . -- Regards, CEO Linux-Online.Ru Korolyov Timofey www.linuxshop.ru :: www.prefnews.ru :: www.dotstyle.ru JabberID: [EMAIL PROTECTED] signature.asc Description: This is a digitally signed message part
RE: 1:n mapping
When i'm saying in my application broker.strore(General) OJB doesn't makes any records in PARTICLE table. Ahh! That's easy: You have to change the collection-descriptor as follows: collection-descriptor name=particles element-class-ref=Particle orderby=particleId sort=DESC auto-update=true inverse-foreignkey field-ref=generalId/ /collection-descriptor cheers, Thomas If you're using OTM, ODMG, or JDO, you need to set auto-update to false. I just have done that - nothing changed . -- Regards, CEO Linux-Online.Ru Korolyov Timofey www.linuxshop.ru :: www.prefnews.ru :: www.dotstyle.ru JabberID: [EMAIL PROTECTED]
RE: 1:n mapping
On Mon, 2003-06-30 at 17:08, Mahler Thomas wrote: When i'm saying in my application broker.strore(General) OJB doesn't makes any records in PARTICLE table. Ahh! That's easy: WoW! That worked but partially ;-) select * from PARTICLE looks like id | name | gid +--+- 3 | AAA | 4 | BBB | but the gid column is empty. And it has to reference GENERAL table's ID-field. May be something is wrong with my reference-descriptor for generalId? -- Regards, CEO Linux-Online.Ru Korolyov Timofey www.linuxshop.ru :: www.prefnews.ru :: www.dotstyle.ru JabberID: [EMAIL PROTECTED] signature.asc Description: This is a digitally signed message part
RE: 1:n mapping
Hi all, Mhh, strange. There is a testcase o.a.ojb.broker.AutomaticForeignKeys that explicitely tests the assignement of foreign keys for such a 1:n association. /** test automatic assignment of foreign keys for 1:n reference. */ public void testOneManyReference() { try { Article art1 = new Article(); art1.setArticleName(TOPLink); Article art2 = new Article(); art2.setArticleName(OJB); Article art3 = new Article(); art3.setArticleName(CASTOR); ProductGroup pg = new ProductGroup(); pg.setName(O/R mapping tools); pg.add(art1); pg.add(art2); pg.add(art3); Identity pgOID = new Identity(pg, broker); broker.store(pg); broker.clearCache(); InterfaceProductGroup readInPG = (InterfaceProductGroup) broker.getObjectByIdentity(pgOID); assertEquals(pg.getName(), readInPG.getName()); assertEquals(pg.getAllArticles().size(), readInPG.getAllArticles().size()); InterfaceArticle art1a = (InterfaceArticle) pg.getAllArticles().get(0); InterfaceArticle art2a = (InterfaceArticle) pg.getAllArticles().get(1); InterfaceArticle art3a = (InterfaceArticle) pg.getAllArticles().get(2); assertEquals(art1.getArticleName(), art1a.getArticleName()); assertEquals(art2.getArticleName(), art2a.getArticleName()); assertEquals(art3.getArticleName(), art3a.getArticleName()); } catch (Throwable t) { System.out.println(t.getMessage()); t.printStackTrace(); fail(t.getMessage()); } } Article has a backreference to Productgroup. this testcase passes, so I have no idea what could be wrong here... cheers, Thomas -Original Message- From: Weaver, Scott [mailto:[EMAIL PROTECTED] Sent: Monday, June 30, 2003 4:08 PM To: 'OJB Users List' Subject: RE: 1:n mapping I have been having the same issue with 1:n mappings were n's FK is not getting updated if n has a reference-descriptor back to 1. *===* * Scott T Weaver * * Jakarta Jetspeed Portal Project * * [EMAIL PROTECTED] * *===* -Original Message- From: Timofey Korolev [mailto:[EMAIL PROTECTED] Sent: Monday, June 30, 2003 9:11 AM To: OJB Users List Subject: RE: 1:n mapping On Mon, 2003-06-30 at 17:08, Mahler Thomas wrote: When i'm saying in my application broker.strore(General) OJB doesn't makes any records in PARTICLE table. Ahh! That's easy: WoW! That worked but partially ;-) select * from PARTICLE looks like id | name | gid +--+- 3 | AAA | 4 | BBB | but the gid column is empty. And it has to reference GENERAL table's ID-field. May be something is wrong with my reference-descriptor for generalId? -- Regards, CEO Linux-Online.Ru Korolyov Timofey www.linuxshop.ru :: www.prefnews.ru :: www.dotstyle.ru JabberID: [EMAIL PROTECTED]
RE: 1:n mapping
Hi Thomas, The test case runs fine, but my implementation is still failing using both ODMG and PB with auto-update/auto-retrieve set to true. I am using field conversions in my PK and FK fields. Could that be a factor? *===* * Scott T Weaver * * Jakarta Jetspeed Portal Project * * [EMAIL PROTECTED] * *===* -Original Message- From: Mahler Thomas [mailto:[EMAIL PROTECTED] Sent: Monday, June 30, 2003 10:11 AM To: 'OJB Users List' Subject: RE: 1:n mapping Hi all, Mhh, strange. There is a testcase o.a.ojb.broker.AutomaticForeignKeys that explicitely tests the assignement of foreign keys for such a 1:n association. /** test automatic assignment of foreign keys for 1:n reference. */ public void testOneManyReference() { try { Article art1 = new Article(); art1.setArticleName(TOPLink); Article art2 = new Article(); art2.setArticleName(OJB); Article art3 = new Article(); art3.setArticleName(CASTOR); ProductGroup pg = new ProductGroup(); pg.setName(O/R mapping tools); pg.add(art1); pg.add(art2); pg.add(art3); Identity pgOID = new Identity(pg, broker); broker.store(pg); broker.clearCache(); InterfaceProductGroup readInPG = (InterfaceProductGroup) broker.getObjectByIdentity(pgOID); assertEquals(pg.getName(), readInPG.getName()); assertEquals(pg.getAllArticles().size(), readInPG.getAllArticles().size()); InterfaceArticle art1a = (InterfaceArticle) pg.getAllArticles().get(0); InterfaceArticle art2a = (InterfaceArticle) pg.getAllArticles().get(1); InterfaceArticle art3a = (InterfaceArticle) pg.getAllArticles().get(2); assertEquals(art1.getArticleName(), art1a.getArticleName()); assertEquals(art2.getArticleName(), art2a.getArticleName()); assertEquals(art3.getArticleName(), art3a.getArticleName()); } catch (Throwable t) { System.out.println(t.getMessage()); t.printStackTrace(); fail(t.getMessage()); } } Article has a backreference to Productgroup. this testcase passes, so I have no idea what could be wrong here... cheers, Thomas -Original Message- From: Weaver, Scott [mailto:[EMAIL PROTECTED] Sent: Monday, June 30, 2003 4:08 PM To: 'OJB Users List' Subject: RE: 1:n mapping I have been having the same issue with 1:n mappings were n's FK is not getting updated if n has a reference-descriptor back to 1. *===* * Scott T Weaver * * Jakarta Jetspeed Portal Project * * [EMAIL PROTECTED] * *===* -Original Message- From: Timofey Korolev [mailto:[EMAIL PROTECTED] Sent: Monday, June 30, 2003 9:11 AM To: OJB Users List Subject: RE: 1:n mapping On Mon, 2003-06-30 at 17:08, Mahler Thomas wrote: When i'm saying in my application broker.strore(General) OJB doesn't makes any records in PARTICLE table. Ahh! That's easy: WoW! That worked but partially ;-) select * from PARTICLE looks like id | name | gid +--+- 3 | AAA | 4 | BBB | but the gid column is empty. And it has to reference GENERAL table's ID-field. May be something is wrong with my reference-descriptor for generalId? -- Regards, CEO Linux-Online.Ru Korolyov Timofey www.linuxshop.ru :: www.prefnews.ru :: www.dotstyle.ru JabberID: [EMAIL PROTECTED]
RE: 1:n mapping
I will try that. Give me a minute and I will let you know. *===* * Scott T Weaver * * Jakarta Jetspeed Portal Project * * [EMAIL PROTECTED] * *===* -Original Message- From: Mahler Thomas [mailto:[EMAIL PROTECTED] Sent: Monday, June 30, 2003 12:28 PM To: 'OJB Users List' Subject: RE: 1:n mapping Hi again, FieldConversions could be a factor. We have testcases for FieldConversions on PrimaryKey fields, but I think no tests for 1:n plus backreference + FieldConversion on foreignkey. Can you modify your setup to test without fieldconversion? cheers, thomas -Original Message- From: Weaver, Scott [mailto:[EMAIL PROTECTED] Sent: Monday, June 30, 2003 6:29 PM To: 'OJB Users List' Subject: RE: 1:n mapping Hi Thomas, The test case runs fine, but my implementation is still failing using both ODMG and PB with auto-update/auto-retrieve set to true. I am using field conversions in my PK and FK fields. Could that be a factor? *===* * Scott T Weaver * * Jakarta Jetspeed Portal Project * * [EMAIL PROTECTED] * *===* -Original Message- From: Mahler Thomas [mailto:[EMAIL PROTECTED] Sent: Monday, June 30, 2003 10:11 AM To: 'OJB Users List' Subject: RE: 1:n mapping Hi all, Mhh, strange. There is a testcase o.a.ojb.broker.AutomaticForeignKeys that explicitely tests the assignement of foreign keys for such a 1:n association. /** test automatic assignment of foreign keys for 1:n reference. */ public void testOneManyReference() { try { Article art1 = new Article(); art1.setArticleName(TOPLink); Article art2 = new Article(); art2.setArticleName(OJB); Article art3 = new Article(); art3.setArticleName(CASTOR); ProductGroup pg = new ProductGroup(); pg.setName(O/R mapping tools); pg.add(art1); pg.add(art2); pg.add(art3); Identity pgOID = new Identity(pg, broker); broker.store(pg); broker.clearCache(); InterfaceProductGroup readInPG = (InterfaceProductGroup) broker.getObjectByIdentity(pgOID); assertEquals(pg.getName(), readInPG.getName()); assertEquals(pg.getAllArticles().size(), readInPG.getAllArticles().size()); InterfaceArticle art1a = (InterfaceArticle) pg.getAllArticles().get(0); InterfaceArticle art2a = (InterfaceArticle) pg.getAllArticles().get(1); InterfaceArticle art3a = (InterfaceArticle) pg.getAllArticles().get(2); assertEquals(art1.getArticleName(), art1a.getArticleName()); assertEquals(art2.getArticleName(), art2a.getArticleName()); assertEquals(art3.getArticleName(), art3a.getArticleName()); } catch (Throwable t) { System.out.println(t.getMessage()); t.printStackTrace(); fail(t.getMessage()); } } Article has a backreference to Productgroup. this testcase passes, so I have no idea what could be wrong here... cheers, Thomas -Original Message- From: Weaver, Scott [mailto:[EMAIL PROTECTED] Sent: Monday, June 30, 2003 4:08 PM To: 'OJB Users List' Subject: RE: 1:n mapping I have been having the same issue with 1:n mappings were n's FK is not getting updated if n has a reference-descriptor back to 1. *===* * Scott T Weaver * * Jakarta Jetspeed Portal Project * * [EMAIL PROTECTED] * *===* -Original Message- From: Timofey Korolev [mailto:[EMAIL PROTECTED] Sent: Monday, June 30, 2003 9:11 AM To: OJB Users List Subject: RE: 1:n mapping On Mon, 2003-06-30 at 17:08, Mahler Thomas wrote: When i'm saying in my application broker.strore(General) OJB doesn't makes any records in PARTICLE table. Ahh! That's easy: WoW! That worked but partially ;-) select * from PARTICLE looks like id | name | gid +--+- 3 | AAA | 4 | BBB | but the gid column is empty. And it has to reference GENERAL table's ID-field. May be something is wrong with my reference-descriptor for generalId