« Return to Thread: committing / rollback question + entitymanager

committing / rollback question + entitymanager

by Leon Derks-2 :: Rate this Message:

Reply to Author | View in Thread

Hello

I have a problem with the rollback of my transaction. For some reason
the entities are saved in the db while the transaction has not committed.

These are the steps:

try{
    logger.debug(" Starting a transaction");
    entityManager.getTransaction().begin();
            //here do some entityManager.persist(entities);
           //then throw a runtime exception to fake an exception.
     logger.debug("Committing the transaction");
     entityManager.getTransaction().commit();
catch(Exception e) {
    logger.error(e);
}
finally {
     if (entityManager != null &&
entityManager.getTransaction().isActive()) {
                logger.debug("Rolling back the transaction");
                entityManager.getTransaction().rollback();
}

This is my logging info:
Starting a transaction
        exception stacktrace...........
Rolling back the transaction

As you can see the transaction is not committed but rolled back. However
there are entities in my db.

How is this possible?
Leon
           

_______________________________________________
eclipselink-users mailing list
eclipselink-users@...
https://dev.eclipse.org/mailman/listinfo/eclipselink-users

 « Return to Thread: committing / rollback question + entitymanager