openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marc Logemann>
Subject re-attach entity and then persisting doesnt work
Date Tue, 15 Dec 2009 13:22:51 GMT

with latest stable OpenJPA i have a problem which might be there because of misunderstanding
on my side.

For instance take these PC class:

Class A {
public int oid;
public String name;
public B classB;

Class B {
public int oid;
public String name;

Now my appCode:

A classA = new A();

B classB = someDao.findClassB();
classA.setB(classB); // classB is detached for this example



When i do this, i am getting the exception that i cant persist a detached class (classB).
This is okay and i am aware of that. Now i tried to attach "B" to the context before persisting


Really interessting is that after the merge, the call to OpenJPAEntityManager.isDetached()
still returns TRUE. Consequently i still cant persist "A". 

So my overall problem is that i cant persist a new Entity when this new entity has a detached
object inside the graph because i cant bring the detached object back into the current context.

Thanks for hints.


View raw message