Java Code Examples for javax.transaction.Transaction#rollback()

The following examples show how to use javax.transaction.Transaction#rollback() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JtaTransactionPolicy.java    From tomee with Apache License 2.0 6 votes vote down vote up
protected void rollbackTransaction(final Transaction tx) throws SystemException {
    try {
        txLogger.debug("TX {0}: Rolling back transaction {1}", transactionType, tx);
        if (tx.equals(transactionManager.getTransaction())) {

            transactionManager.rollback();
        } else {
            tx.rollback();
        }
    } catch (final IllegalStateException | javax.transaction.SystemException e) {

        logger.error("The TransactionManager reported an exception while attempting to rollback the transaction: " + e.getMessage());
        throw new SystemException(e);

    }
}
 
Example 2
Source File: DefaultTransactionManager.java    From piranha with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Rollback the transaction.
 *
 * @throws IllegalStateException when the transaction is not active.
 * @throws SecurityException when a security error occurs.
 * @throws SystemException when a serious error occurs.
 */
@Override
public void rollback() throws IllegalStateException, SecurityException,
        SystemException {
    Transaction transaction = getTransaction();
    try {
        transaction.rollback();
    } finally {
        Thread currentThread = Thread.currentThread();
        threadTransactionMap.remove(currentThread);
    }
}
 
Example 3
Source File: TransactionManagerImpl.java    From clearpool with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void rollback() throws SecurityException, SystemException {
  Transaction action = TX_HOLDER.get();
  if (action == null) {
    throw new ConnectionPoolException("this is no transaction holding");
  }
  try {
    action.rollback();
  } finally {
    TX_HOLDER.set(null);
  }
}
 
Example 4
Source File: TxBeanManaged.java    From tomee with Apache License 2.0 5 votes vote down vote up
public void destroy() {
    final Transaction beanTransaction = transaction;
    transaction = null;
    if (beanTransaction == null) {
        return;
    }

    try {
        beanTransaction.rollback();
    } catch (final Exception e) {
        logger.error("Error rolling back suspended transaction for discarded stateful session bean instance");
    }
}