Search in sources :

Example 1 with RollbackStateTransitionException

use of org.datanucleus.exceptions.RollbackStateTransitionException in project datanucleus-core by datanucleus.

the class ExecutionContextImpl method preRollback.

/**
 * Rollback any changes made to objects managed by the object manager to the database.
 */
public void preRollback() {
    List<Exception> failures = null;
    try {
        Collection<ObjectProvider> ops = enlistedOPCache.values();
        Iterator<ObjectProvider> opsIter = ops.iterator();
        while (opsIter.hasNext()) {
            ObjectProvider op = opsIter.next();
            try {
                op.preRollback(getTransaction());
            } catch (RuntimeException e) {
                if (failures == null) {
                    failures = new ArrayList();
                }
                failures.add(e);
            }
        }
        clearDirty();
    } finally {
        resetTransactionalVariables();
    }
    if (failures != null && !failures.isEmpty()) {
        throw new RollbackStateTransitionException(failures.toArray(new Exception[failures.size()]));
    }
    if (getBooleanProperty(PropertyNames.PROPERTY_DETACH_ALL_ON_ROLLBACK)) {
        // "detach-on-rollback"
        performDetachAllOnTxnEndPreparation();
    }
}
Also used : RollbackStateTransitionException(org.datanucleus.exceptions.RollbackStateTransitionException) ArrayList(java.util.ArrayList) ObjectProvider(org.datanucleus.state.ObjectProvider) ClassNotDetachableException(org.datanucleus.exceptions.ClassNotDetachableException) NucleusObjectNotFoundException(org.datanucleus.exceptions.NucleusObjectNotFoundException) RollbackStateTransitionException(org.datanucleus.exceptions.RollbackStateTransitionException) NucleusException(org.datanucleus.exceptions.NucleusException) NucleusFatalUserException(org.datanucleus.exceptions.NucleusFatalUserException) ClassNotPersistableException(org.datanucleus.exceptions.ClassNotPersistableException) NoPersistenceInformationException(org.datanucleus.exceptions.NoPersistenceInformationException) TransactionActiveOnCloseException(org.datanucleus.exceptions.TransactionActiveOnCloseException) NucleusUserException(org.datanucleus.exceptions.NucleusUserException) ClassNotResolvedException(org.datanucleus.exceptions.ClassNotResolvedException) NucleusOptimisticException(org.datanucleus.exceptions.NucleusOptimisticException) CommitStateTransitionException(org.datanucleus.exceptions.CommitStateTransitionException) TransactionNotActiveException(org.datanucleus.exceptions.TransactionNotActiveException) ObjectDetachedException(org.datanucleus.exceptions.ObjectDetachedException)

Aggregations

ArrayList (java.util.ArrayList)1 ClassNotDetachableException (org.datanucleus.exceptions.ClassNotDetachableException)1 ClassNotPersistableException (org.datanucleus.exceptions.ClassNotPersistableException)1 ClassNotResolvedException (org.datanucleus.exceptions.ClassNotResolvedException)1 CommitStateTransitionException (org.datanucleus.exceptions.CommitStateTransitionException)1 NoPersistenceInformationException (org.datanucleus.exceptions.NoPersistenceInformationException)1 NucleusException (org.datanucleus.exceptions.NucleusException)1 NucleusFatalUserException (org.datanucleus.exceptions.NucleusFatalUserException)1 NucleusObjectNotFoundException (org.datanucleus.exceptions.NucleusObjectNotFoundException)1 NucleusOptimisticException (org.datanucleus.exceptions.NucleusOptimisticException)1 NucleusUserException (org.datanucleus.exceptions.NucleusUserException)1 ObjectDetachedException (org.datanucleus.exceptions.ObjectDetachedException)1 RollbackStateTransitionException (org.datanucleus.exceptions.RollbackStateTransitionException)1 TransactionActiveOnCloseException (org.datanucleus.exceptions.TransactionActiveOnCloseException)1 TransactionNotActiveException (org.datanucleus.exceptions.TransactionNotActiveException)1 ObjectProvider (org.datanucleus.state.ObjectProvider)1