Return-Path: Delivered-To: apmail-openjpa-users-archive@locus.apache.org Received: (qmail 94092 invoked from network); 7 Apr 2008 12:10:07 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 7 Apr 2008 12:10:07 -0000 Received: (qmail 71964 invoked by uid 500); 7 Apr 2008 12:10:08 -0000 Delivered-To: apmail-openjpa-users-archive@openjpa.apache.org Received: (qmail 71792 invoked by uid 500); 7 Apr 2008 12:10:07 -0000 Mailing-List: contact users-help@openjpa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@openjpa.apache.org Delivered-To: mailing list users@openjpa.apache.org Received: (qmail 71783 invoked by uid 99); 7 Apr 2008 12:10:07 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 07 Apr 2008 05:10:07 -0700 X-ASF-Spam-Status: No, hits=1.2 required=10.0 tests=SPF_HELO_PASS,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [212.227.126.186] (HELO moutng.kundenserver.de) (212.227.126.186) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 07 Apr 2008 12:09:24 +0000 Received: from [192.168.0.234] (host86-129-117-158.range86-129.btcentralplus.com [86.129.117.158]) by mrelayeu.kundenserver.de (node=mrelayeu0) with ESMTP (Nemesis) id 0MKwh2-1Jiq9r1dd0-0008FK; Mon, 07 Apr 2008 14:09:07 +0200 Message-ID: <47FA0EDE.10902@cyberspaceroad.org> Date: Mon, 07 Apr 2008 13:09:02 +0100 From: Adam Hardy User-Agent: Icedove 1.5.0.14pre (X11/20080305) MIME-Version: 1.0 To: users@openjpa.apache.org Subject: persisting an entity and JPA behaviour with referenced entities Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V01U2FsdGVkX1/BZH6YRoetOuGBHAnSQSL1oOKD8hTIyWARH4O 4/64gDQ+mwKjpScDyjqjHG04aOxU9SGeSwvmNuTw+1hQtJSiEI kh8SjdS/rt6rPP9VhvzsqWqQOH2pHlJ X-Virus-Checked: Checked by ClamAV on apache.org I've got an issue with the persist operation, when I use a detached entity as one of the entity's referenced entities. OpenJPA throws the org.apache.openjpa.persistence.EntityExistsException: Attempt to persist detached object "org.apache.openjpa.enhance.org$permacode$atomictest$domain$Genus$pcsubclass@1c527be". The situation is this: my MVC layer has received a new entity which it must create. The parent entity for this is found in a cache, in a detached state. What I'd like to know, is why is JPA forcing me to merge this detached entity before allowing me to persist the new child? It means I can't use the cache, or I have to program the DAO to merge all referenced entities. This latter option seems like a job that JPA should be doing. JPA knows this parent is a detached entity, so why can't it merge the managed entity? I can't see any text in the EJB spec that would mandate this behaviour, yet Hibernate does it too. Regards Adam