openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gurkan Erdogdu (JIRA)" <>
Subject [jira] [Commented] (OPENJPA-673) Entity using Generated Value for primary key and a Version field and no DetachedStae fails to merge
Date Wed, 12 Jun 2013 05:33:19 GMT


Gurkan Erdogdu commented on OPENJPA-673:

Hello Kevin

Issue is that

- Persist a new entity in a new transaction. Entity name is : Address
- Merge a new entity which includes List<Address> in a new transaction. It throws the
exception as :

I tried all 2.x.x versions, all of them are failed! (I said that 2.1.1 works but this is my
fault, it does not work!)

Jun 11, 2013 11:55:53 AM org.apache.geronimo.transaction.manager.TransactionImpl beforeCompletion
WARNING: Unexpected exception from beforeCompletion; transaction will roll back
<openjpa-2.1.1-r422266:1148538 nonfatal user error> org.apache.openjpa.persistence.InvalidStateException:
Primary key field of
has non-default value. The instance life cycle is in PNewProvisionalState 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.
	at org.apache.openjpa.util.ApplicationIds.assign(
	at org.apache.openjpa.util.ApplicationIds.assign(
	at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.assignObjectId(
	at org.apache.openjpa.kernel.DelegatingStoreManager.assignObjectId(
	at org.apache.openjpa.kernel.StateManagerImpl.assignObjectId(
	at org.apache.openjpa.kernel.StateManagerImpl.preFlush(
	at org.apache.openjpa.kernel.PNewProvisionalState.nonprovisional(
	at org.apache.openjpa.kernel.StateManagerImpl.nonprovisional(
	at org.apache.openjpa.kernel.SingleFieldManager.preFlushPC(
	at org.apache.openjpa.kernel.SingleFieldManager.preFlushPCs(
	at org.apache.openjpa.kernel.SingleFieldManager.preFlush(
	at org.apache.openjpa.kernel.SingleFieldManager.preFlush(
	at org.apache.openjpa.kernel.SingleFieldManager.preFlush(
	at org.apache.openjpa.kernel.StateManagerImpl.preFlush(
	at org.apache.openjpa.kernel.PNewState.beforeFlush(
	at org.apache.openjpa.kernel.StateManagerImpl.beforeFlush(
	at org.apache.openjpa.kernel.BrokerImpl.flush(
	at org.apache.openjpa.kernel.BrokerImpl.flushSafe(
	at org.apache.openjpa.kernel.BrokerImpl.beforeCompletion(
	at org.apache.geronimo.transaction.manager.TransactionImpl.beforeCompletion(
	at org.apache.geronimo.transaction.manager.TransactionImpl.beforeCompletion(
	at org.apache.geronimo.transaction.manager.TransactionImpl.beforePrepare(
	at org.apache.geronimo.transaction.manager.TransactionImpl.commit(
	at org.apache.geronimo.transaction.manager.TransactionManagerImpl.commit(
	at org.apache.openejb.core.transaction.JtaTransactionPolicy.completeTransaction(
	at org.apache.openejb.core.transaction.TxRequired.commit(
	at org.apache.openejb.core.transaction.EjbTransactionUtil.afterInvoke(
	at org.apache.openejb.core.stateless.StatelessContainer._invoke(
	at org.apache.openejb.core.stateless.StatelessContainer.invoke(
	at org.apache.openejb.core.ivm.EjbObjectProxyHandler.synchronizedBusinessMethod(
	at org.apache.openejb.core.ivm.EjbObjectProxyHandler.businessMethod(
	at org.apache.openejb.core.ivm.EjbObjectProxyHandler._invoke(
	at org.apache.openejb.core.ivm.BaseEjbProxyHandler.invoke(

Code example:
@Stateless class PersoneController{
     //JTA based entity manager
     @PersistenceContext EntityManager em;
     //Person is a new object 
     public void merge(Person person){


class Client{

   public void main(){
      //Address is already in database 
      Address address = EntityManager.find(Address.class,1);

      Person p = new Person();

> Entity using Generated Value for primary key and a Version field and no DetachedStae
fails to merge 
> ----------------------------------------------------------------------------------------------------
>                 Key: OPENJPA-673
>                 URL:
>             Project: OpenJPA
>          Issue Type: Bug
>            Reporter: Pinaki Poddar
> Entities using GeneratedValue for primary key, a version field an dno detached state
fails to merge.
> The issue lies with identifying :"what makes a new instance?"
> It is not obvious why VersionAttachStrategy does not use version field to detect newness.
Instead it depends on detached state which is obviously null for instances not using a Detached
> Can someone shade some light on why VersionAttachStrategy ignores version field to detect

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see:

View raw message