Return-Path: Delivered-To: apmail-openjpa-users-archive@locus.apache.org Received: (qmail 90938 invoked from network); 30 Dec 2007 18:36:53 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 30 Dec 2007 18:36:53 -0000 Received: (qmail 63519 invoked by uid 500); 30 Dec 2007 18:36:41 -0000 Delivered-To: apmail-openjpa-users-archive@openjpa.apache.org Received: (qmail 63497 invoked by uid 500); 30 Dec 2007 18:36:41 -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 63488 invoked by uid 99); 30 Dec 2007 18:36:41 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 30 Dec 2007 10:36:41 -0800 X-ASF-Spam-Status: No, hits=2.6 required=10.0 tests=DNS_FROM_OPENWHOIS,SPF_HELO_PASS,SPF_PASS,WHOIS_MYPRIVREG X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of lists@nabble.com designates 216.139.236.158 as permitted sender) Received: from [216.139.236.158] (HELO kuber.nabble.com) (216.139.236.158) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 30 Dec 2007 18:36:18 +0000 Received: from isper.nabble.com ([192.168.236.156]) by kuber.nabble.com with esmtp (Exim 4.63) (envelope-from ) id 1J931K-00065X-87 for users@openjpa.apache.org; Sun, 30 Dec 2007 10:36:22 -0800 Message-ID: <14549852.post@talk.nabble.com> Date: Sun, 30 Dec 2007 10:36:22 -0800 (PST) From: Pinaki Poddar To: users@openjpa.apache.org Subject: Re: How to attach an existing, detached object to a new entity and save new entity? In-Reply-To: <14545985.post@talk.nabble.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Nabble-From: ppoddar@apache.org References: <14545985.post@talk.nabble.com> X-Virus-Checked: Checked by ClamAV on apache.org Does Country object declare a @Version field? mxc wrote: > > Hi all, > > In my application a user edits an entry in a form which allows the user to > select the foreign objects from a list box which has been populated via a > jpa query. (The context has been closed and hence the object is detached.) > So for example if the object customer has a manytoone relationship to > country the country drop down allows selection of the country. > > When trying to persist the customer object I get an error about the > country object already having an id value set and that this causes > problems with auto-generation. It appears that openjpa is attemtping to > persist the country object insead of just attaching it and seeing it is > already in the database. How can I fix this? I have tried > cascade={CascadeType.ALL} on both sides of the relationship with no luck > :( > > thanks > > -- View this message in context: http://www.nabble.com/How-to-attach-an-existing%2C-detached-object-to-a-new-entity-and-save-new-entity--tp14545985p14549852.html Sent from the OpenJPA Users mailing list archive at Nabble.com.