Example usage for javax.transaction Transaction commit

List of usage examples for javax.transaction Transaction commit

Introduction

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

Prototype

public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException,
        SecurityException, IllegalStateException, SystemException;

Source Link

Document

Complete the transaction represented by this Transaction object.

Usage

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

@Override
public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException,
        SecurityException, IllegalStateException, SystemException {
    Transaction tx = threadLocal.get();

    try {/*w  ww  .  j  a  v  a  2 s  .  co m*/
        if (tx != null) {
            log.info("Commiting transaction:" + tx);
            tx.commit();
        } else {
            log.debug("Cannot locate a transaction to commit.");

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

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

public void commit() {
    beginOperation(false);/*from  w  ww .j  a v a2  s  .co m*/
    try {
        assertTransactionOperation();

        javax.transaction.Transaction trans = _runtime.getTransactionManager().getTransaction();
        if (trans == null)
            throw new InvalidStateException(_loc.get("null-trans"));

        // this commit on the transaction will cause our
        // beforeCompletion method to be invoked
        trans.commit();
    } 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();
    }
}

From source file:org.mule.test.integration.transaction.XAResourceManagerTestCase.java

@Test
public void testTxBehaviour() throws Exception {
    TestXAResourceManager rm = new TestXAResourceManager();
    rm.start();//from ww w  .  ja  va2  s . c o  m
    DefaultXASession s = rm.createSession();

    tm.begin();
    Transaction tx = tm.getTransaction();
    tx.enlistResource(s);

    tx.delistResource(s, XAResource.TMSUCCESS);
    tx.commit();
}