openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Adam Borkowski (JIRA)" <>
Subject [jira] Created: (OPENJPA-1640) Rollback in extended persistence context doesn't move persistent object to new/transient state
Date Sun, 25 Apr 2010 16:37:49 GMT
Rollback in extended persistence context doesn't move persistent object to new/transient state

                 Key: OPENJPA-1640
             Project: OpenJPA
          Issue Type: Bug
    Affects Versions: 1.2.2
            Reporter: Adam Borkowski

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*,
* = 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();


      //assertFalse("Persistent object should be in New state after rollback", manager.isDetached(notif));

      EntityTransaction transaction2 = manager.getTransaction();

      manager.persist(persistentObject);    // this line throws exception


This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message