I want to do a simple thing, just attach and already persisted child to a new
parent and save the parent (and therefore the reference):

Role role = new Role(...);
manager..store(role)

Role loadedRole = manager..load(<role_id>);

Account account = new Account();
account.getRoles().add(loadedRole);
manager..store(account);

You'd think that would be a simple procedure, but I'm getting this somewhat
cryptic error.


<openjpa-1.0.0-r420667:568756 nonfatal user error>
org.apache.openjpa.persistence.InvalidStateException: Encountered unmanaged
object
"org.apache.openjpa.enhance.com$lobbythem$model$Role$pcsubclass-com.lobbythem.model.Role-2"
in persistent field "com.lobbythem.model.Account.roles<element:class
com.lobbythem.model.Role>" of managed object
"[EMAIL PROTECTED]" during flush.  However, this field
does not allow cascade persist.  You cannot flush unmanaged
objects.FailedObject:
org.apache.openjpa.enhance.com$lobbythem$model$Role$pcsubclass-com.lobbythem.model.Role-2

What is the process for doing this common operation with JPA so it actually
works?

- Brill
-- 
View this message in context: 
http://www.nabble.com/Help%3A-Attaching-an-already-persisted-object-to-a-new-parent.-tf4776024.html#a13661947
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Reply via email to