Example usage for org.springframework.transaction HeuristicCompletionException STATE_ROLLED_BACK

List of usage examples for org.springframework.transaction HeuristicCompletionException STATE_ROLLED_BACK

Introduction

In this page you can find the example usage for org.springframework.transaction HeuristicCompletionException STATE_ROLLED_BACK.

Prototype

int STATE_ROLLED_BACK

To view the source code for org.springframework.transaction HeuristicCompletionException STATE_ROLLED_BACK.

Click Source Link

Document

Rolledback outcome state.

Usage

From source file:bigbank.transaction.ChainedTransactionManager.java

@Override
public void commit(TransactionStatus status) throws TransactionException {

    MultiTransactionStatus multiTransactionStatus = (MultiTransactionStatus) status;

    boolean commit = true;
    Exception commitException = null;
    PlatformTransactionManager commitExceptionTransactionManager = null;

    for (PlatformTransactionManager transactionManager : reverse(transactionManagers)) {
        if (commit) {
            try {
                multiTransactionStatus.commit(transactionManager);
            } catch (Exception ex) {
                commit = false;/*  w  w  w.  j  ava  2  s.  c  o m*/
                commitException = ex;
                commitExceptionTransactionManager = transactionManager;
            }
        } else {
            // after unsucessfull commit we must try to rollback remaining
            // transaction managers
            try {
                multiTransactionStatus.rollback(transactionManager);
            } catch (Exception ex) {
                logger.warn("Rollback exception (after commit) (" + transactionManager + ") " + ex.getMessage(),
                        ex);
            }
        }
    }

    if (multiTransactionStatus.isNewSynchonization()) {
        synchronizationManager.clearSynchronization();
    }

    if (commitException != null) {
        boolean firstTransactionManagerFailed = commitExceptionTransactionManager == getLastTransactionManager();
        int transactionState = firstTransactionManagerFailed ? HeuristicCompletionException.STATE_ROLLED_BACK
                : HeuristicCompletionException.STATE_MIXED;
        throw new HeuristicCompletionException(transactionState, commitException);
    }

}

From source file:com.zhengmo.data.transaction.ChainedTransactionManager.java

@Override
public void commit(TransactionStatus status) throws TransactionException {
    MultiTransactionStatus multiTransactionStatus = (MultiTransactionStatus) status;
    boolean commit = true;
    Exception commitException = null;
    PlatformTransactionManager commitExceptionTransactionManager = null;
    for (PlatformTransactionManager transactionManager : reverse(transactionManagers)) {
        if (commit) {
            try {
                multiTransactionStatus.commit(transactionManager);
            } catch (Exception ex) {
                commit = false;/* w w  w . j av a2s  . c om*/
                commitException = ex;
                commitExceptionTransactionManager = transactionManager;
            }
        } else {
            // after unsucessfull commit we must try to rollback remaining transaction managers
            try {
                multiTransactionStatus.rollback(transactionManager);
            } catch (Exception ex) {
                LOGGER.warn("Rollback exception (after commit) (" + transactionManager + ") " + ex.getMessage(),
                        ex);
            }
        }
    }
    if (multiTransactionStatus.isNewSynchonization()) {
        synchronizationManager.clearSynchronization();
    }
    if (commitException != null) {
        boolean firstTransactionManagerFailed = commitExceptionTransactionManager == getLastTransactionManager();
        int transactionState = firstTransactionManagerFailed ? HeuristicCompletionException.STATE_ROLLED_BACK
                : HeuristicCompletionException.STATE_MIXED;
        throw new HeuristicCompletionException(transactionState, commitException);
    }
}

From source file:com.becool.base.spring.tx.ChainedTransactionManager.java

public void commit(TransactionStatus status) throws TransactionException {

    MultiTransactionStatus multiTransactionStatus = (MultiTransactionStatus) status;

    boolean commit = true;
    Exception commitException = null;
    PlatformTransactionManager commitExceptionTransactionManager = null;

    for (PlatformTransactionManager transactionManager : reverse(transactionManagers)) {

        if (commit) {

            try {
                multiTransactionStatus.commit(transactionManager);
            } catch (Exception ex) {
                commit = false;//from  www  . j  ava  2  s  .  com
                commitException = ex;
                commitExceptionTransactionManager = transactionManager;
            }

        } else {

            // after unsucessfull commit we must try to rollback remaining transaction managers

            try {
                multiTransactionStatus.rollback(transactionManager);
            } catch (Exception ex) {
                LOGGER.warn("Rollback exception (after commit) (" + transactionManager + ") " + ex.getMessage(),
                        ex);
            }
        }
    }
    if (multiTransactionStatus.isNewSynchonization()) {
        synchronizationManager.clearSynchronization();
    }

    if (commitException != null) {
        boolean firstTransactionManagerFailed = commitExceptionTransactionManager == getLastTransactionManager();
        int transactionState = firstTransactionManagerFailed ? HeuristicCompletionException.STATE_ROLLED_BACK
                : HeuristicCompletionException.STATE_MIXED;
        throw new HeuristicCompletionException(transactionState, commitException);
    }
}

From source file:org.danielli.xultimate.transaction.ChainedTransactionManager.java

public void commit(TransactionStatus status) throws TransactionException {

    MultiTransactionStatus multiTransactionStatus = (MultiTransactionStatus) status;

    boolean commit = true;
    Exception commitException = null;
    PlatformTransactionManager commitExceptionTransactionManager = null;

    for (PlatformTransactionManager transactionManager : reverse(transactionManagers)) {

        if (commit) {

            try {
                multiTransactionStatus.commit(transactionManager);
            } catch (Exception ex) {
                commit = false;/*  ww  w  .ja  v a  2 s. c  o  m*/
                commitException = ex;
                commitExceptionTransactionManager = transactionManager;
            }

        } else {

            // after unsucessfull commit we must try to rollback remaining transaction managers

            try {
                multiTransactionStatus.rollback(transactionManager);
            } catch (Exception ex) {
                LOGGER.warn("Rollback exception (after commit) (" + transactionManager + ") " + ex.getMessage(),
                        ex);
            }
        }
    }

    if (multiTransactionStatus.isNewSynchonization()) {
        synchronizationManager.clearSynchronization();
    }

    if (commitException != null) {
        boolean firstTransactionManagerFailed = commitExceptionTransactionManager == getLastTransactionManager();
        int transactionState = firstTransactionManagerFailed ? HeuristicCompletionException.STATE_ROLLED_BACK
                : HeuristicCompletionException.STATE_MIXED;
        throw new HeuristicCompletionException(transactionState, commitException);
    }
}

From source file:de.faustedition.db.ChainedTransactionManager.java

@Override
public void commit(TransactionStatus status) throws TransactionException {

    MultiTransactionStatus multiTransactionStatus = (MultiTransactionStatus) status;

    boolean commit = true;
    Exception commitException = null;
    PlatformTransactionManager commitExceptionTransactionManager = null;

    for (PlatformTransactionManager transactionManager : reverse(transactionManagers)) {
        if (commit) {
            try {
                multiTransactionStatus.commit(transactionManager);
            } catch (Exception ex) {
                commit = false;/*from  w w  w  . j  a v  a 2s.c om*/
                commitException = ex;
                commitExceptionTransactionManager = transactionManager;
            }
        } else {
            //after unsucessfull commit we must try to rollback remaining transaction managers
            try {
                multiTransactionStatus.rollback(transactionManager);
            } catch (Exception ex) {
                logger.warn("Rollback exception (after commit) (" + transactionManager + ") " + ex.getMessage(),
                        ex);
            }
        }
    }

    if (multiTransactionStatus.isNewSynchonization()) {
        synchronizationManager.clearSynchronization();
    }

    if (commitException != null) {
        boolean firstTransactionManagerFailed = commitExceptionTransactionManager == getLastTransactionManager();
        int transactionState = firstTransactionManagerFailed ? HeuristicCompletionException.STATE_ROLLED_BACK
                : HeuristicCompletionException.STATE_MIXED;
        throw new HeuristicCompletionException(transactionState, commitException);
    }

}