From dev-return-7825-apmail-openjpa-dev-archive=openjpa.apache.org@openjpa.apache.org Fri Apr 11 16:49:02 2008 Return-Path: Delivered-To: apmail-openjpa-dev-archive@www.apache.org Received: (qmail 55478 invoked from network); 11 Apr 2008 16:49:02 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 11 Apr 2008 16:49:02 -0000 Received: (qmail 61226 invoked by uid 500); 11 Apr 2008 16:49:01 -0000 Delivered-To: apmail-openjpa-dev-archive@openjpa.apache.org Received: (qmail 61211 invoked by uid 500); 11 Apr 2008 16:49:01 -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 61034 invoked by uid 99); 11 Apr 2008 16:49:00 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 11 Apr 2008 09:49:00 -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; Fri, 11 Apr 2008 16:48:16 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id F3A9E234C0C4 for ; Fri, 11 Apr 2008 09:46:04 -0700 (PDT) Message-ID: <480835004.1207932364996.JavaMail.jira@brutus> Date: Fri, 11 Apr 2008 09:46:04 -0700 (PDT) From: "Sandeep Shrivastava (JIRA)" To: dev@openjpa.apache.org Subject: [jira] Updated: (OPENJPA-568) Delete, re-insert and setting relationship in the same transaction results in In-Reply-To: <1130039369.1207931405974.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-568?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Sandeep Shrivastava updated OPENJPA-568: ---------------------------------------- Attachment: openjpa-1.1.0-SNAPSHOT-r420667.634150.patch The fix to the VersionAttachStrategy class that addresses this issue. > Delete, re-insert and setting relationship in the same transaction results in > ------------------------------------------------------------------------------ > > Key: OPENJPA-568 > URL: https://issues.apache.org/jira/browse/OPENJPA-568 > Project: OpenJPA > Issue Type: Bug > Components: kernel > Affects Versions: 1.1.0 > Environment: This problem is reported with OpenJPA version: > $ java org.apache.openjpa.conf.OpenJPAVersion > OpenJPA 1.1.0-SNAPSHOT > version id: openjpa-1.1.0-SNAPSHOT-r420667:634150 > Apache svn revision: 420667:634150 > os.name: Windows XP > os.version: 5.1 > os.arch: x86 > java.version: 1.6.0_05 > java.vendor: BEA Systems, Inc. > Reporter: Sandeep Shrivastava > Fix For: 1.1.0 > > Attachments: openjpa-1.1.0-SNAPSHOT-r420667.634150.patch > > Original Estimate: 24h > Remaining Estimate: 24h > > The test deletes and instance and creates another with the same primary keys and encounters an exception while making the new one persistent. > Here is the snippet from the test code: > pm.currentTransaction().begin(); > MappingTest2 test2c = new MappingTest2(); > test2c.setPk1(test2b.getPk1()); > test2c.setPk2(test2b.getPk2()); > pm.deletePersistent(test2b); > test4.getNManyMap().put("key2", test2); > test4.getManyManyMap().remove(test2b); > test4.getManyManyMap().put(test2, test2); > pm.makePersistent(test2c); > test4.setInverseOneOne(test2c); > MappingTest4 test4c = new MappingTest4(); > test4c.setInverseOwnerOneOne(test2c); > test2c.setOneOneOwner(test4c); > pm.makePersistent(test4c); > pm.currentTransaction().commit(); > The problem with this issue was that the JDO PersistenceManager. makePersistent() is failing with the following exception: > [testlogic] > kodo.jdo.UserException: Operation attempted on a deleted instance. > [testlogic] FailedObject: kodo.jdbc.meta.MappingTest2-3::4 > [testlogic] at org.apache.openjpa.kernel.PCState.error(PCState.java:443) > [testlogic] at > org.apache.openjpa.kernel.PDeletedState.beforeOptimisticWrite(PDeletedState.java:76) > [testlogic] at > org.apache.openjpa.kernel.StateManagerImpl.dirty(StateManagerImpl.java:1571) > [testlogic] at > org.apache.openjpa.kernel.StateManagerImpl.settingObjectField(StateManagerImpl.java:1898) > [testlogic] at > org.apache.openjpa.kernel.AttachStrategy.attachField(AttachStrategy.java:204) > [testlogic] at > org.apache.openjpa.kernel.VersionAttachStrategy.attach(VersionAttachStrategy.java:164) > [testlogic] at > org.apache.openjpa.kernel.AttachManager.attach(AttachManager.java:241) > [testlogic] at > org.apache.openjpa.kernel.VersionAttachStrategy.attachInPlace(VersionAttachStrategy.java:267) > [testlogic] at > org.apache.openjpa.kernel.VersionAttachStrategy.attachFieldsInPlace(VersionAttachStrategy.java:218) > [testlogic] at > org.apache.openjpa.kernel.VersionAttachStrategy.attach(VersionAttachStrategy.java:133) > [testlogic] at > org.apache.openjpa.kernel.AttachManager.attach(AttachManager.java:241) > [testlogic] at > org.apache.openjpa.kernel.AttachManager.attach(AttachManager.java:101) > [testlogic] at > org.apache.openjpa.kernel.BrokerImpl.attach(BrokerImpl.java:3191) > [testlogic] at kodo.kernel.KodoBroker.attach(KodoBroker.java:251) > [testlogic] at > org.apache.openjpa.kernel.DelegatingBroker.attach(DelegatingBroker.java:1142) > [testlogic] at > kodo.jdo.PersistenceManagerImpl.makePersistent(PersistenceManagerImpl.java:496) > [testlogic] at > kodo.jdbc.kernel.TestFlush.testDeleteAndReInsert(TestFlush.java:124) > Synopsis: > When the second call to pm.makePersistent(test2c) is made it is not attached correctly. The effect of the prior pm.deletePersistent(test2b) which deletes the object with the same key is kept in the persistence context and hence when a relation is established with the deleted entity the third pm.makePersistent(test4c) call throws the above exception. > The fix that I have is to correct the logic in the org.apache.openjpa.kernel.VersionAttachStrategy.attach() method where it tries to make a determination of whether this is a new object by also checking whether the existing entity is deleted or not. And that fixes the problem. I will attach it as a patch shortly. > Thanks > Sandeep -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.