Yep!!! That's it, now m:n relations are working fine. I must admit that 
I'd never studied the dtd - shame on me. I think I also read it 
somewhere in the docs but unfortunately I sticked to the repository.xml 
entries from the example in the docs. Anyway, now it works only if  I 
store the object A before I update the object B by adding object A to 
its collection. This must be due to the auto-update=false.

Thank you very much David.

/olaf


To stick to my previous simplified notation with the Person <-> Project 
example:

I did:
<snippet>
tx.begin();
doris = new Person();

proj = query(Project.class, "select x where id=1");
tx.lock(proj, tx.WRITE);
proj.getCollectionPerson().add(doris);
tx.commit();
</snippet>

But now I do:
(Store the new Person, update the Project and add the Person)
<snippet>
tx.begin();
doris = new Person();
tx.lock(doris, tx.WRITE);
tx.commit();

tx.begin();
proj = query(Project.class, "select x where id=1");
tx.lock(proj, tx.WRITE);
proj.getCollectionPerson().add(doris);
tx.commit();
</snippet>

What also works is this:
(If Person is new then add the Project and store the Person)
<snippet>
v = new Vector();
proj = query(Project.class, "select x where id=1");
v.add(proj);

tx.begin()
doris = new Person();
doris.setCollectionProject(v);
tx.lock(doris, tx.WRITE);
tx.commit();
</snippet>


David Raphael wrote:

> 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





--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to