openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pushpraj <>
Subject Re: AW: Exception during the unit tests in Eclipse(including maven)
Date Wed, 05 Sep 2012 09:41:39 GMT

I was also getting the same exception.
EJB threw an unexpected (non-declared) exception during invocation of method
"test123" on bean "BeanId(test-ear#test-1-in-ejb.jar#MsgPersist, null)".
Exception data: <openjpa-2.1.2-SNAPSHOT-r422266:1179900 fatal user error>

nvalidStateException: Primary key field
com.cah.nfp.test.RetryMessage.retryNumber of
com.cah.test.RetryMessage@744014f has non-default value. The instance life
cycle is in PNewState state and hence an existing non-default value for the
identity field is

not permitted. You either need to remove the @GeneratedValue annotation or
modify the code to remove the initializer processing./

And in my case it was because. I was trying to update the same object in two
different Transactions.

First I fetched the records from DB using JPA then, trying to call merge in
new transaction. As JPA select already took lock in record, and merger is
also trying to update the record. so *PNewState state * was comming.

By using *WITH UR* in query, problem is resolved.

View this message in context:
Sent from the OpenJPA Users mailing list archive at

View raw message