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 - 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 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: 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
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: 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 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? . 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: - 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.(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 org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getObjectByQuery(Un known Source) at org.apache.ojb.broker.singlevm.DelegatingPersistenceBroker.getObjectByQu ery(Unknown Source) at com.mps.safari.util.dbaccess.PersistenceManager.getObjectById(Persistenc eManager.java:112) at TestOjb.main(TestOjb.java:16) [org.apache.ojb.broker.accesslayer.RsIterator] ERROR: 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.(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
Re: 1:n mapping
hi scott, imo this method should look lik: if ((objectOrProxy instanceof Proxy) && Proxy.isProxyClass(objectOrProxy.getClass())) { IndirectionHandler handler; handler = (IndirectionHandler) Proxy.getInvocationHandler((Proxy) objectOrProxy); return getKeyValues(cld, handler.getIdentity(), convertToSql); // BRJ: convert Identity } else if (objectOrProxy instanceof VirtualProxy) { IndirectionHandler handler; handler = (IndirectionHandler) VirtualProxy.getIndirectionHandler((VirtualProxy) objectOrProxy); return getKeyValues(cld, handler.getIdentity(), convertToSql); // BRJ: convert Identity } else { ClassDescriptor realCld = getRealClassDescriptor(cld, objectOrProxy); return getValuesForObject(realCld.getPkFields(), objectOrProxy, convertToSql); } jakob Jakob Braeuchi wrote: 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]
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
RE: 1:n mapping
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 PRO
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: '
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 >
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
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 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
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
> > 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: 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 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
What type of problem are you having? If you're using OTM, ODMG, or JDO, you need to set auto-update to false. Eric -Original Message- From: Timofey Korolev [mailto:[EMAIL PROTECTED] Sent: Monday, June 30, 2003 8:38 AM To: OJB Users List Subject: 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 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] DISCLAIMER: The information contained in this e-mail is, unless otherwise indicated, confidential and is intended solely for the use of the named addressee. Access, copying or re-use of the e-mail or any information contained therein by any other person is not authorized. If you are not the intended recipient please notify us immediately by returning the e-mail to the originator.
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 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
Hope this helps, I am assuming that the problem is the Repository.xml file < Class def agreement> 1:M <- points to Agreement ID N:M With Intersection Table -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
I had also some troubles wuth the repository.xml and the field-id-ref. Now I use field-ref and it seems oK. -Message d'origine- De : [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Envoyé : mardi 25 mars 2003 18:16 À : OJB Users List Objet : 1->n mapping I don't seem to be able to have any working sample with a 1 to n mappig, I would greatly appreciate if someone could send me one. Regards, Patrick Reyes - 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]