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]
> 

Reply via email to