openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jody Grassel (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (OPENJPA-2405) EntityManager.merge does not work for entity that is managed by another EntityManager
Date Fri, 28 Jun 2013 20:33:20 GMT

     [ https://issues.apache.org/jira/browse/OPENJPA-2405?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Jody Grassel updated OPENJPA-2405:
----------------------------------

    Attachment: openjpa-2405-2.1.x.patch

I propose the attached fix for this issue, which allows the reporter's sample test to pass.

Basically the idea is simple: check if the object to be merged (toAttach) has a StateManager
associated with it.  If it does and that StateManager is a StateManagerImpl (which DetachedStateManager
is not a descendent of) then grab its broker reference.

If this broker reference is different than the broker being used to perform the merge() operation,
then set isManagedByAnotherPCtx=true.

Then modify isNew to the following logic:

boolean isNew = !broker.isDetached(pc) && !isManagedByAnotherPCtx;

Basically, if toAttach is not detached and it is not managed by another persistence context,
then it is to be considered a new object.

(Disclaimer: have not run the full junit suite yet, will do so after posting this.)
                
> 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-2.1.x.patch, 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

Mime
View raw message