Hello, 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> org.apache.openjpa.persistence.I
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: http://openjpa.208410.n2.nabble.com/Exception-during-the-unit-tests-in-Eclipse-including-maven-tp7570130p7581020.html Sent from the OpenJPA Users mailing list archive at Nabble.com.