[
https://issues.apache.org/jira/browse/OPENJPA-1640?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Rick Curtis reassigned OPENJPA-1640:
------------------------------------
Assignee: Rick Curtis
> Rollback in extended persistence context doesn't move persistent object to
> new/transient state
> ----------------------------------------------------------------------------------------------
>
> Key: OPENJPA-1640
> URL: https://issues.apache.org/jira/browse/OPENJPA-1640
> Project: OpenJPA
> Issue Type: Bug
> Affects Versions: 1.2.2
> Reporter: Adam Borkowski
> Assignee: Rick Curtis
>
> According to the diagram which describes lifecycle of the entity on page 71
> of the 1.2.2 manual,
> one can see that from "managed" state entity can go back to "New/Transient"
> by rollback*, where
> * = Extended persistence context
> It seems that it's not the case. I'm using extended persistence context in a
> standalone application.
> When trying to persist object after it was persisted and transaction was
> rolled back, I get following exception:
> "<openjpa-1.2.2-r422266:898935 nonfatal store error>
> org.apache.openjpa.persistence.EntityExistsException: Attempt to persist
> detached object "PersistentObjectDBImpl@f38cf0". If this is a new instance,
> make sure any version and/or auto-generated primary key fields are
> null/default when persisting."
> It looks like after rollback entity goes to the "detached" state.
> This behavior prevents from performing simple retry of transaction operating
> on the same persistent objects in case of some problems (ex. deadlock)
> Following piece of code illustrates the problem:
> OpenJPAEntityManager manager = factory.createEntityManager();
> try {
> EntityTransaction transaction = manager.getTransaction();
> transaction.begin();
> manager.persist(persistentObject);
> transaction.rollback();
> //assertFalse("Persistent object should be in New state after
> rollback", manager.isDetached(notif));
> EntityTransaction transaction2 = manager.getTransaction();
> transaction2.begin();
> manager.persist(persistentObject); // this line throws exception
> transaction2.commit();
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira