I had a similar problem with Collections. In the collection descriptor there is a field for auto-retrieve and auto-update. When I set auto-update to false, but keep auto-retrieve as true it works perfectly. The reason why this happens is because the ODMG API takes care of
This is explained in the repository.dtd file I quote the specific section: "The auto-update attribute specifies whether OJB automatically stores this reference attribute on storing the persistent object. This attribute must be set to false if using the OTM, ODMG or JDO layer." I hope this helps, -David Raphael >From: Olaf <[EMAIL PROTECTED]> >Reply-To: [EMAIL PROTECTED] >To: [EMAIL PROTECTED] >Subject: Re: Another=>Problem with m:n association, duplicate when updating >object >Date: Fri, 06 Sep 2002 00:39:22 +0200 > >ODMG M:N problems > >I also tried it but exactly the same happened to me. > >Ricardo Kohler wrote: >>When inserting objects (using m:n decomposed) ODMG try to >>insert twice my object into the table. Like they said in >>the other message I tryed to put auto-update=false... >>But it gives a different error then: "Parent key FK_Pacient >>not found". I noted that ODMG try to insert data into the >>intermediary table before than in the other, because it >>inserts into the both other. > >There must be a bug resulting in wrong inserts/updates. > >When sticking to the person <-> project example from the tutorial in a >simplified notation: > ><snippet> >doris = new Person(); > >proj = query(Project.class, "select x where id=1"); >tx.lock(proj, tx.WRITE); >proj.getCollectionPerson().add(doris); >tx.commit(); > >proj = query(Project.class, "select x where id=2"); >tx.lock(proj, tx.WRITE); >proj.getCollectionPerson().add(doris); >tx.commit(); ></snippet> > >results in only one new row in the intermediary table which is a relation >between doris >and project.id=2. > >Table project_person: >person_id project_id >1 2 > > ><snippet> >doris = new Person(); >james = new Person(); > >proj = query(Project.class, "select x where id=1"); >tx.lock(proj, tx.WRITE); >proj.getCollectionPerson().add(doris); >tx.commit(); > >proj = query(Project.class, "select x where id=1"); >tx.lock(proj, tx.WRITE); >proj.getCollectionPerson().add(james); >tx.commit(); > >proj = query(Project.class, "select x where id=2"); >tx.lock(proj, tx.WRITE); >proj.getCollectionPerson().add(doris); >tx.commit(); ></snippet> > >results in the intermediary table correctly with two 'doris' rows to >project.id=1 and project.id=2 and in one 'james' row. But it seems that the >inserts are perfomed twice >as I'm getting an error from my sql server (hsqldb) that it can't insert >(values(1, 1)) >because the index must be unique. I think it probably inserts the whole >collection again. > >Table project_person: >person_id project_id >1 1 >1 2 >2 1 > > >Maybe I'll migrate my project to the PersistenceBroker API. If I would have >more time I >would take a deeper look at the sources. > >/olaf > > > >-- >To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> >For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> _________________________________________________________________ Chat with friends online, try MSN Messenger: http://messenger.msn.com -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>