From dev-return-9226-apmail-openjpa-dev-archive=openjpa.apache.org@openjpa.apache.org Mon Sep 22 17:11:05 2008 Return-Path: Delivered-To: apmail-openjpa-dev-archive@www.apache.org Received: (qmail 19162 invoked from network); 22 Sep 2008 17:11:05 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 22 Sep 2008 17:11:05 -0000 Received: (qmail 76516 invoked by uid 500); 22 Sep 2008 17:11:02 -0000 Delivered-To: apmail-openjpa-dev-archive@openjpa.apache.org Received: (qmail 76493 invoked by uid 500); 22 Sep 2008 17:11:02 -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 76482 invoked by uid 99); 22 Sep 2008 17:11:02 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 22 Sep 2008 10:11:02 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 22 Sep 2008 17:10:10 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 3ADAF234C1D4 for ; Mon, 22 Sep 2008 10:10:44 -0700 (PDT) Message-ID: <969608194.1222103444233.JavaMail.jira@brutus> Date: Mon, 22 Sep 2008 10:10:44 -0700 (PDT) From: "Xiaoqin Feng (JIRA)" To: dev@openjpa.apache.org Subject: [jira] Commented: (OPENJPA-722) persist - clear - merge scenario doesn't work In-Reply-To: <1837151779.1221174824215.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/OPENJPA-722?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12633384#action_12633384 ] Xiaoqin Feng commented on OPENJPA-722: -------------------------------------- Jeremy, Good thoughts about test. I am fine with the other proposed solution. I am looking forward to look at your solution. > persist - clear - merge scenario doesn't work > --------------------------------------------- > > Key: OPENJPA-722 > URL: https://issues.apache.org/jira/browse/OPENJPA-722 > Project: OpenJPA > Issue Type: Sub-task > Components: kernel > Affects Versions: 1.0.3, 1.1.0, 1.2.0 > Reporter: Xiaoqin Feng > Assignee: Jeremy Bauer > Attachments: openjpa-722-fromQin.patch, TestEntityManagerClear-V2.java, TestEntityManagerClear.java > > > EntityManager.clear() now don't flush new object but only detach it. > But DetachManager still flush dirty object and assume detached objects are in clean state. > When the "new" object is merged back and transaction commit, because the object state lost its original state PNEW, it will not be added to insert list and not flushed to DB. > According to the EntityManager.clear() API, changes made to entities that have not been flushed to the database will not be persisted. When they merges back to persistent context, they all should kept there original state. > I added the following test to org.apache.openjpa.persistence.simple.TestEntityManagerClear. > public void testClearMerge() { > // Create EntityManager and Start a transaction (1) > begin(); > // Insert a new object then clear persistent context > AllFieldTypes testObject1 = new AllFieldTypes(); > testObject1.setStringField("my test object1"); > persist(testObject1); > //Object1 is not flushed to DB but only detached by clear(). > em.clear(); > em.merge(testObject1); > //expect the PCState is same as before detached, > //so it is PNew instead of PCLEAN and is add to insert list. > commit(); > > //Start a new transaction > begin(); > > // Attempt retrieve of Object1 from previous PC (should exist) > assertEquals(1, query("select x from AllFieldTypes x " > + "where x.stringField = 'my test object1'"). > getResultList().size()); > > // Rollback the transaction and close everything > rollback(); > } -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.