Return-Path: Delivered-To: apmail-openjpa-dev-archive@www.apache.org Received: (qmail 34895 invoked from network); 4 May 2009 19:37:09 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 4 May 2009 19:37:09 -0000 Received: (qmail 62534 invoked by uid 500); 4 May 2009 19:37:09 -0000 Delivered-To: apmail-openjpa-dev-archive@openjpa.apache.org Received: (qmail 62465 invoked by uid 500); 4 May 2009 19:37:09 -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 62455 invoked by uid 99); 4 May 2009 19:37:09 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 04 May 2009 19:37:09 +0000 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of curtisr7@gmail.com designates 74.125.44.29 as permitted sender) Received: from [74.125.44.29] (HELO yx-out-2324.google.com) (74.125.44.29) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 04 May 2009 19:37:02 +0000 Received: by yx-out-2324.google.com with SMTP id 8so2385591yxm.63 for ; Mon, 04 May 2009 12:36:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type; bh=MmHJYR7XRZJdIm1NT0HheQrJQt4hFklYN/hyzbeEXXo=; b=WSOPyzJV2d/SJwTlTGzlLG7xHz1+YnXdPPxS7QdgKF4eQuCSr+rVEthSS9pRENkWdF IebQ4MLwqyGqnz8QhqkSjESI1kI2Nzt9tx1d078PPchmR5WFaQMKfm3rz520Yrj8c16b PQqO+1dUoUKSeJAtJgp7krgmZHiHyG6455StU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=UZyDMNRvhu3+OF9gSElp0cPhrU5XjkLPoNtvlJza4TBC+MRGF1UqvSK/LFMpVsO9uC +HJVaxCMOXM/CuijK8Ho+LEYRM4JE0qoUuA7y7J4Z/VGYdl+TDTFHTl8EMgK0fVP29zZ jiqgTxR+OgVsJBq0uT0ZX4Ts6U/HaNENdwPbE= MIME-Version: 1.0 Received: by 10.151.74.1 with SMTP id b1mr12405667ybl.241.1241465801661; Mon, 04 May 2009 12:36:41 -0700 (PDT) In-Reply-To: <49FF415E.9000802@gmail.com> References: <49FF415E.9000802@gmail.com> Date: Mon, 4 May 2009 14:36:41 -0500 Message-ID: Subject: Re: Generated ID starts with 0 From: Rick Curtis To: dev@openjpa.apache.org Content-Type: multipart/alternative; boundary=001e680f0c881be40004691b48de X-Virus-Checked: Checked by ClamAV on apache.org --001e680f0c881be40004691b48de Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Try adding a version column to your Entity, or stop using primitives for your id columns. OpenJPA does not know the difference between an id that has a value of zero, and one that is uninitialized. -Rick On Mon, May 4, 2009 at 2:26 PM, B.J. Reed wrote: > I have a testcase where a DB2 DB is already created. It has 2 tables and > the web user preferences table has an identity column that is defined as > "generated always as identity (start with 0, ..." > > In the test case, I am expecting 2 sets of 2 inserts each into this table. > The first 2 objects should have id's of 0 and 1 (works fine) and the 2nd > set should have id's of 2 and 3 - what happens is that the web user > preference entities have never had their id set so both of their ids are > defaulted to 0. In stead of inserting rows, the entity manager sees the id > of 0 on both 2nd set objects and then does an update in the DB on the very > first record (since that one's id correctly is 0). > > Should OpenJPA be able to handle a generated column that starts with 0 (I > can create a JIRA for an enhancement) or is it common knowledge that the DB > should start with a non zero number or is there something that I should set > the id to in the new web user preferece entities so that they will always be > inserted? > > By changing the DDL to start with 1 in stead of 0, this problem is avoided > and 4 rows are inserted into the DB properly with id's 1 - 4. > > --B.J. Reed > --001e680f0c881be40004691b48de--