Hi,

It sounds like your facade on top of JPA is causing the work that
you're doing to span multiple persistence contexts (multiple
transactions, basically), and thus causing the role instance to be
detached.

Ideally, it's probably worth investigating to make sure the "right"
thing is happening wrt. your transaction boundaries.

If you set up your cascade settings correctly, then you'll probably be
able to trivially work around the problem, but bear in mind that that
might just end up masking a larger issue.

-Patrick

On Nov 8, 2007 9:45 PM, Brill Pappin <[EMAIL PROTECTED]> wrote:
>
> 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.
>
>



-- 
Patrick Linskey
202 669 5907

Reply via email to