openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rick Curtis (JIRA)" <>
Subject [jira] [Assigned] (OPENJPA-1640) Rollback in extended persistence context doesn't move persistent object to new/transient state
Date Thu, 31 Mar 2011 21:23:05 GMT


Rick Curtis reassigned OPENJPA-1640:

    Assignee: Rick Curtis

> Rollback in extended persistence context doesn't move persistent object to new/transient
> ----------------------------------------------------------------------------------------------
>                 Key: OPENJPA-1640
>                 URL:
>             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
> one can see that from "managed" state entity can go back to "New/Transient" by rollback*,
> * = Extended persistence context 
> It seems that it's not the case. I'm using extended persistence context in a standalone
> 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:

View raw message