Return-Path: Delivered-To: apmail-db-jdo-user-archive@www.apache.org Received: (qmail 41461 invoked from network); 20 Oct 2006 10:04:36 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 20 Oct 2006 10:04:36 -0000 Received: (qmail 54870 invoked by uid 500); 20 Oct 2006 10:04:31 -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 54858 invoked by uid 99); 20 Oct 2006 10:04:30 -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 03:04:30 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [202.238.89.128] (HELO bioscene.co.jp) (202.238.89.128) by apache.org (qpsmtpd/0.29) with SMTP; Fri, 20 Oct 2006 03:04:11 -0700 Received: (qmail 2765 invoked from network); 20 Oct 2006 10:16:08 -0000 Received: from unknown (HELO eth0.sonoda) (192.168.2.5) by bioscene.co.jp with SMTP; 20 Oct 2006 10:16:08 -0000 Subject: Attaching a unique, existing object as a field From: David Leangen To: jdo-user@db.apache.org Content-Type: text/plain Date: Fri, 20 Oct 2006 19:01:13 +0900 Message-Id: <1161338473.30392.5.camel@sonoda.bioscene.co.jp> Mime-Version: 1.0 X-Mailer: Evolution 2.6.0 (2.6.0-1) Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N 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!