[
https://issues.apache.org/jira/browse/OPENJPA-2405?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13695705#comment-13695705
]
Jody Grassel commented on OPENJPA-2405:
---------------------------------------
Looking at the attached test, my opinion is that the following should happen:
1) The call to populate(), before the test begins, creates a new em, adds a row
to the database, commits, and destroys the em.
2) Enter testMergeManagedParent()
3) Parent parent = em.find(Parent.class, pk); - returns an instance of Parent
(id=K1) with an address of, say, @0000001.
4) Parent mergedParent = em2.merge(parent); - sees parent is not "new" (because
it has a StateManager), and that its associated StateManager belongs to em and
not em2, should view parent as a detached entity - so it should perform a fetch
from the database, create a new object, say, @0000002, and bring in any fields
which have been mutated in @0000001 (which in this case, are none), and return
@0000001 to the caller which is saved in the mergedParent field.
It's a little different scenario than what I was initially led to believe (I
thought the scenario would have been the em from step #3 was creating a new
entity object instance, here, the row already exists on the db before the test
logic runs.)
Does anyone disagree with 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.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