[ 
https://issues.apache.org/jira/browse/OPENJPA-2405?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13695651#comment-13695651
 ] 

Jody Grassel commented on OPENJPA-2405:
---------------------------------------

Further Thoughts, as I realize the statement "A managed entity instance is an 
instance with a persistent identity that is currently associated with a 
persistence context." could be read differently than how I read it (using the 
2.1 spec, which should not be different from previous spec iterations.)

3.2.8 Managed Instances
It is the responsibility of the application to insure that an instance is 
managed in only a single persistence context. The behavior is undefined if the 
same Java instance is made managed in more than one persistence context.

The contains() method can be used to determine whether an entity instance is 
managed in the current persistence context.

-- What I take from here is that from the perspective of a Persistence Context, 
an entity is managed if and only if it is actively associated with it.  So an 
Entity Object instance with a StateManager associated with PCtx#1 is a "managed 
entity" only from the perspective of PCtx#1 (emPCTX1.contains(entity) returns 
true).  Any other PCtxs, such as PCtx#2 would see that it has a StateManager 
that is not associated with it so it is neither "new" nor "managed" (by PCtx#2) 
and should consider it to be unmanaged (detached, since it cannot be a "new" 
entity for reasons previously stated) - in this case emPCTX2(entity) returns 
false.
                
> EntityManager.merge does not work for entity that is managed by another 
> EntityManager
> -------------------------------------------------------------------------------------
>
>                 Key: OPENJPA-2405
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2405
>             Project: OpenJPA
>          Issue Type: Bug
>    Affects Versions: 2.2.3
>            Reporter: Arne Limburg
>         Attachments: OPENJPA-2405.patch
>
>
> EntityManager.merge does not work for entity that is managed by another 
> EntityManager. Instead of updating that entity OpenJPA tries to persist the 
> entity a second time

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to