Return-Path: Delivered-To: apmail-db-jdo-user-archive@www.apache.org Received: (qmail 72968 invoked from network); 20 Oct 2006 11:25:07 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 20 Oct 2006 11:25:07 -0000 Received: (qmail 54436 invoked by uid 500); 20 Oct 2006 11:25:06 -0000 Mailing-List: contact jdo-user-help@db.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: jdo-user@db.apache.org Delivered-To: mailing list jdo-user@db.apache.org Received: (qmail 54425 invoked by uid 99); 20 Oct 2006 11:25:06 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 20 Oct 2006 04:25:06 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: neutral (asf.osuosl.org: local policy) Received: from [216.148.213.132] (HELO smtp.mailix.net) (216.148.213.132) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 20 Oct 2006 04:25:02 -0700 Received: from [192.168.8.8] (helo=localhost) by smtp.mailix.net with asmtp (Exim 4.24-BE) id 1GasUH-0002jS-Ay for jdo-user@db.apache.org; Fri, 20 Oct 2006 04:24:29 -0700 Received: from sle-beasy2-2-0.sprintlink.net (sle-beasy2-2-0.sprintlink.net [82.195.189.166]) by webmail.jpox.org (IMP) with HTTP for ; Fri, 20 Oct 2006 04:24:38 -0700 Message-ID: <1161343478.4538b1f65387f@webmail.jpox.org> Date: Fri, 20 Oct 2006 04:24:38 -0700 From: Erik Bengtson To: jdo-user@db.apache.org References: <1161338473.30392.5.camel@sonoda.bioscene.co.jp> In-Reply-To: <1161338473.30392.5.camel@sonoda.bioscene.co.jp> MIME-Version: 1.0 User-Agent: Internet Messaging Program (IMP) 3.2.3 X-Originating-IP: 82.195.189.166 X-SA-Exim-Mail-From: erik@jpox.org Subject: Re: Attaching a unique, existing object as a field Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-SA-Exim-Version: 3.1 (built Thu Oct 23 13:26:47 PDT 2003) X-SA-Exim-Scanned: No; Unknown failure X-uvscan-result: clean (1GasUH-0002jS-Ay) X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Enable debug mode in logs and it will output the state of instances. Quoting David Leangen : > Hello! > > I have a PC container class that holds another PC class as a field, and > the field has a unique id constraint. > > When inserting the container class into the DB (it is loaded from an > external source), I first check to see if the field already exists in > the DB and, if so, I attach it to the containing class. For example: > > ContainerClass container = getContainerClass(); > FieldClass unmanagedField = container.getField(); > FieldClass managedField = getFieldFromDb( unmanagedField ); > if( managedField != null ) > container.setField( managedField ); > insertContainerClassIntoDb(); > > > However, I am getting an exception that complains about a duplicate key > constraint. > > My assumption was that since the field is already managed, it would not > be re-inserted by the framework. > > To accomplish what I'm trying to do, what state do I need to put the PC > field into so it does not get re-inserted? > > > [BTW, I am currently using JPox as my JDO2 implementation. I was told > there to ask on this list about what the specs say should be done.] > > Thank you! > > >