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

Reply via email to