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 07BC79635 for ; Thu, 23 Feb 2012 12:48:15 +0000 (UTC) Received: (qmail 76003 invoked by uid 500); 23 Feb 2012 12:48:14 -0000 Delivered-To: apmail-openjpa-dev-archive@openjpa.apache.org Received: (qmail 75912 invoked by uid 500); 23 Feb 2012 12:48:13 -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 75900 invoked by uid 99); 23 Feb 2012 12:48:13 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 23 Feb 2012 12:48:13 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 23 Feb 2012 12:48:11 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id 0148B336D83 for ; Thu, 23 Feb 2012 12:47:50 +0000 (UTC) Date: Thu, 23 Feb 2012 12:47:50 +0000 (UTC) From: "Vermeulen (Commented) (JIRA)" To: dev@openjpa.apache.org Message-ID: <1237525685.9596.1330001270006.JavaMail.tomcat@hel.zones.apache.org> In-Reply-To: <1967877091.12385.1301088305875.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Commented] (OPENJPA-1966) Entity graphs containing bi-directional references may not merge correctly if an entity does not contain a state manager MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/OPENJPA-1966?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13214596#comment-13214596 ] Vermeulen commented on OPENJPA-1966: ------------------------------------ We are experiencing exactly this problem with all our cascading relations of the form A <- OneToMany -> B. We prefer using detached entities without a state manager because we have a client-server system where the client may insert/update entities through the server. What we get on merging A is A' -> B'_i, with B'_i -> A. An easy workaround for us is to manually set the reference from each B'_i to A' after detaching. However it would be very nice if this bug is fixed because this is easy to forget when working with a new entity. > Entity graphs containing bi-directional references may not merge correctly if an entity does not contain a state manager > ------------------------------------------------------------------------------------------------------------------------ > > Key: OPENJPA-1966 > URL: https://issues.apache.org/jira/browse/OPENJPA-1966 > Project: OpenJPA > Issue Type: Bug > Components: kernel > Affects Versions: 1.0.4, 1.2.2, 2.0.1, 2.1.0 > Reporter: Jeremy Bauer > Assignee: Jeremy Bauer > Attachments: OPENJPA-1966.patch, OPENJPA-1966.patch > > > An entity graph (with cascade) containing bi-directional relationships or circular references may fail to merge properly if one or more of the entities in the graph do not have a state manager - either an active or detached state manager. The result is that one or more of the merged entities may end up with a reference to a detached object. This may not be immediately evident and could cause problems in subsequent operations. It can even affect the ordering of SQL statements since foreign keys may not be properly associated with the detached entities. > For example: A <- OneToOne -> B > em.clear() > Detached graph: B <--> A > A: Is detached, has DetachedStateManager > B: Is detached, No state manager, only detached state field. (ie. @DetachedState Object state) > Merge: B > After merge: B' --> A' --> B (detached) > If B contains a state manager the result of the merge is correct: B' <--> A' > The source of the problem is that the "no state manager" attachment path creates a new PC + state manager and assigns this state manager to the detached instance so that it can be used to attach all its fields. During a cascade, this detached entity (with borrowed state manager) looks persistent, so it can get attached into the resulting merge graph. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira