Example usage for javax.transaction Transaction rollback

List of usage examples for javax.transaction Transaction rollback

Introduction

In this page you can find the example usage for javax.transaction Transaction rollback.

Prototype

public void rollback() throws IllegalStateException, SystemException;

Source Link

Document

Rollback the transaction represented by this Transaction object.

Usage

From source file:com.impetus.kundera.persistence.jta.KunderaJTAUserTransaction.java

@Override
public void rollback() throws IllegalStateException, SecurityException, SystemException {
    if (isTransactionInProgress) {
        try {/*from www  .  j  ava 2 s  . c o  m*/
            Transaction tx = threadLocal.get();
            if (tx == null) {
                throw new IllegalStateException("Cannot locate a Transaction for rollback.");
            }

            log.info("Rollback transaction:" + tx);

            tx.rollback();

        } finally {
            log.info("Resetting after rollback.");
            threadLocal.set(null);
            timerThead.set(null);
        }
    } else {

        throw new KunderaException("No transaction in progress.");
    }
}

From source file:org.apache.openjpa.kernel.BrokerImpl.java

public void rollback() {
    beginOperation(false);/*from   www.  jav  a  2 s .  c om*/
    try {
        assertTransactionOperation();

        javax.transaction.Transaction trans = _runtime.getTransactionManager().getTransaction();
        if (trans != null)
            trans.rollback();
    } catch (OpenJPAException ke) {
        if (_log.isTraceEnabled())
            _log.trace(_loc.get("end-trans-error"), ke);
        throw ke;
    } catch (Exception e) {
        if (_log.isTraceEnabled())
            _log.trace(_loc.get("end-trans-error"), e);
        throw new StoreException(e);
    } finally {
        endOperation();
    }
}