Return-Path: X-Original-To: apmail-openjpa-users-archive@minotaur.apache.org Delivered-To: apmail-openjpa-users-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id BB94C9149 for ; Tue, 22 May 2012 06:02:07 +0000 (UTC) Received: (qmail 27938 invoked by uid 500); 22 May 2012 06:02:07 -0000 Delivered-To: apmail-openjpa-users-archive@openjpa.apache.org Received: (qmail 27445 invoked by uid 500); 22 May 2012 06:02:02 -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 26729 invoked by uid 99); 22 May 2012 06:02:00 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 22 May 2012 06:02:00 +0000 X-ASF-Spam-Status: No, hits=1.3 required=5.0 tests=SPF_PASS,URI_HEX X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Received: from [194.147.70.15] (HELO mail.bertschi.com) (194.147.70.15) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 22 May 2012 06:01:54 +0000 Received: from DUEEXS06.bertschi.domain ([169.254.2.202]) by dueexs03.bertschi.domain ([::1]) with mapi id 14.02.0283.003; Tue, 22 May 2012 08:01:33 +0200 From: Boblitz John To: "'users@openjpa.apache.org'" Subject: AW: Exception during the unit tests in Eclipse(including maven) Thread-Topic: Exception during the unit tests in Eclipse(including maven) Thread-Index: AQHNN72/3Y7nle32202TFnSp1l3FDJbVTqJQ Date: Tue, 22 May 2012 06:01:32 +0000 Message-ID: <88CB62524DE0644AAE21D8BAB8CFC0CA01A0630E@dueexs06.bertschi.domain> References: <1337640002132-7570130.post@n2.nabble.com> In-Reply-To: <1337640002132-7570130.post@n2.nabble.com> Accept-Language: de-CH, en-US Content-Language: de-DE X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [172.28.164.129] Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Hello, When persisting an entry, you may not put a value in your PK if it is a gen= erated key! Likely you have, somewhere, something like this: @Entity public class Member { =20 .... @ID @GeneratedValue(...) private ... userId; And, in the populating method: Member member =3D new Member(); member.setUserId(fromXmlMember.getUserId()); <- do not do this! ... Em.persist(member); Hope this helps, =EF=BB=BF=20 John ----=20 Who is General Failure, and why is he reading my hard disk? =20 > -----Urspr=FCngliche Nachricht----- > Von: schamarthi [mailto:srinivas.chamarthi@gmail.com]=20 > Gesendet: Dienstag, 22. Mai 2012 00:40 > An: users@openjpa.apache.org > Betreff: Exception during the unit tests in Eclipse(including maven) >=20 > I am populating data from xml and persisting entities using=20 > entitymanager during my application startup and everything is=20 > fine. But however I am trying to run the junits with setup=20 > containing the script to load the test data by persisting=20 > them using entitymanager, I am seeing the following exception... >=20 > PS: I haven't set any userId value in my unit tests.=20 >=20 > not sure what does this mean.... am not able to get away with=20 > this exception. appreciate any quick help.=20 >=20 >=20 > Primary key field com.all4u.server.domain.Member.userId of > com.all4u.server.domain.Member@187e184 has non-default value.=20 > The instance life cycle is in PNewState state and hence an=20 > existing non-default value for the identity field is not=20 > permitted. You either need to remove the @GeneratedValue=20 > annotation or modify the code to remove the initializer=20 > processing.; nested exception is=20 > =20 > org.apache.openjpa.persistence.InvalidStateException: Primary=20 > key field com.all4u.server.domain.Member.userId of > com.all4u.server.domain.Member@187e184 has non-default value.=20 > The instance life cycle is in PNewState state and hence an=20 > existing non-default value for the identity field is not=20 > permitted. You either need to remove the @GeneratedValue=20 > annotation or modify the code to remove the initializer processing. >=20 > -- > View this message in context:=20 > http://openjpa.208410.n2.nabble.com/Exception-during-the-unit- > tests-in-Eclipse-including-maven-tp7570130.html > Sent from the OpenJPA Users mailing list archive at Nabble.com. > =