openjpa-users mailing list archives

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

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();
a.setName("foo");

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

em.persist(classA);


=====

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
via:

em.merge(classB);

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.




---
regards
Marc




Mime
View raw message