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

robert engels commented on OPENJPA-2405:
----------------------------------------

If I change the update code to the following, it works as expected - but again, 
no need to do this with EclipseLink, and it certainly seems like a bug. If 
cascading is not enabled for the ManyToOne relationship, it shouldn't even care 
about the persisted state of the Country object, it should just be using it's 
ID to form the relation. Only if the Country object had no ID should there be a 
failure.

 
{code:java}
customer.getHomeAddress().setCountry(entityManager.merge(customer.getHomeAddress().getCountry()));
this.entityManager.merge(customer);
return "view?faces-redirect=true&id=" + this.customer.getId();

{code}

> 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
>          Components: kernel
>    Affects Versions: 2.2.3
>            Reporter: Arne Limburg
>            Assignee: Jody Grassel
>            Priority: Major
>             Fix For: 2.3.0
>
>         Attachments: OPENJPA-2405.patch
>
>   Original Estimate: 2h
>  Remaining Estimate: 2h
>
> 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 was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to