Return-Path: Delivered-To: apmail-openjpa-dev-archive@www.apache.org Received: (qmail 6951 invoked from network); 1 May 2008 19:04:47 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 1 May 2008 19:04:47 -0000 Received: (qmail 81174 invoked by uid 500); 1 May 2008 19:04:48 -0000 Delivered-To: apmail-openjpa-dev-archive@openjpa.apache.org Received: (qmail 81011 invoked by uid 500); 1 May 2008 19:04:48 -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 81000 invoked by uid 99); 1 May 2008 19:04:48 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 01 May 2008 12:04:48 -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; Thu, 01 May 2008 19:04:03 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id C4BDD234C112 for ; Thu, 1 May 2008 12:00:57 -0700 (PDT) Message-ID: <1949992494.1209668457804.JavaMail.jira@brutus> Date: Thu, 1 May 2008 12:00:57 -0700 (PDT) From: "Jason Zheng (JIRA)" To: dev@openjpa.apache.org Subject: [jira] Created: (OPENJPA-585) Got EntityExistsException when invoking EntityManager.merge() to persist a new entity bean with generated id and enhanced at deployment time MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Got EntityExistsException when invoking EntityManager.merge() to persist a new entity bean with generated id and enhanced at deployment time ---------------------------------------------------------------------------------------------------------------------------------------------- Key: OPENJPA-585 URL: https://issues.apache.org/jira/browse/OPENJPA-585 Project: OpenJPA Issue Type: Bug Components: kernel Affects Versions: 1.1.0 Reporter: Jason Zheng I create a new entity object with generated id, enhance it at deployment time and persist it into db by invoking EntityManager.merge(). Department d = new Department(); d.setName('qa'); pc.merge(d); Got below exception, org.apache.openjpa.persistence.EntityExistsException: Attempt to persist detached object 'org.apache.openjpa.enhance.tests$functional$jee$misc$classredefinition$common$apps$appforredefinition$entity$Department$pcsubclass@acb905'. If this is a new instance, make sure any versino and/or auto-generated primary key fields are null/default when persisting. FailedObject: org.apache.openjpa.enhance.tests$functional$jee$misc$classredefinition$common$apps$appforredefinition$entity$Department$pcsubclass@acb905 at org.apache.openjpa.kernel.BrokerImpl.persist(BrokerImpl.java:2403) at org.apache.openjpa.kernel.AttachStrategy.persist(AttachStrategy.java:94) at org.apache.openjpa.kernel.VersionAttachStrategy.attach(VersionAttachStrategy.java:95) at org.apache.openjpa.kernel.AttachManager.attach(AttachManager.java:241) at org.apache.openjpa.kernel.AttachManager.attach(AttachManager.java:101) at org.apache.openjpa.kernel.BrokerImpl.attach(BrokerImpl.java:3191) at kodo.kernel.KodoBroker.attach(KodoBroker.java:251) at org.apache.openjpa.kernel.DelegatingBroker.attach(DelegatingBroker.java:1142) at org.apache.openjpa.persistence.EntityManagerImpl.merge(EntityManagerImpl.java:740) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at weblogic.deployment.BasePersistenceContextProxyImpl.invoke(BasePersistenceContextProxyImpl.java:90) ... This is caused by a bug in VersionAttachStrategy, which creates appId and passes it to persist() call for a new entity whose id is annotated with @GeneratedValue. Jason -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.