Return-Path: X-Original-To: apmail-openjpa-dev-archive@www.apache.org Delivered-To: apmail-openjpa-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 355E010A6A for ; Fri, 28 Jun 2013 18:40:21 +0000 (UTC) Received: (qmail 86825 invoked by uid 500); 28 Jun 2013 18:40:20 -0000 Delivered-To: apmail-openjpa-dev-archive@openjpa.apache.org Received: (qmail 86784 invoked by uid 500); 28 Jun 2013 18:40:20 -0000 Mailing-List: contact dev-help@openjpa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@openjpa.apache.org Delivered-To: mailing list dev@openjpa.apache.org Received: (qmail 86715 invoked by uid 99); 28 Jun 2013 18:40:20 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 28 Jun 2013 18:40:20 +0000 Date: Fri, 28 Jun 2013 18:40:20 +0000 (UTC) From: "Jody Grassel (JIRA)" To: dev@openjpa.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (OPENJPA-2405) EntityManager.merge does not work for entity that is managed by another EntityManager MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ 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