/** * INTERNAL: * Commit the external transaction. * * @param session The session for which the transaction is being committed. */ public void commitTransaction(AbstractSession session) { try { Object status = getTransactionStatus(); logTxStateTrace(session, "TX_commit", status); if (canCommitTransaction_impl(status)) { logTxTrace(session, "TX_committingTxn", null); session.setWasJTSTransactionInternallyStarted(false); commitTransaction_impl(); } } catch (Exception exception) { throw TransactionException.errorCommittingExternalTransaction(exception); } }
/** * INTERNAL: * Begin an external transaction. * * @param session The session for which the transaction is being begun. */ public void beginTransaction(AbstractSession session) { try { Object status = getTransactionStatus(); logTxStateTrace(session, "TX_begin", status); // Make sure that we are in a state that we can actually start // a transaction (e.g. ensure one is not already in progress) if (canBeginTransaction_impl(status)) { logTxTrace(session, "TX_beginningTxn", null); beginTransaction_impl(); session.setWasJTSTransactionInternallyStarted(true); } } catch (Exception exception) { throw TransactionException.errorBeginningExternalTransaction(exception); } }
/** * INTERNAL: * Roll back the external transaction. * * @param session The session for which the transaction is being rolled back. */ public void rollbackTransaction(AbstractSession session) { try { Object status = getTransactionStatus(); logTxStateTrace(session, "TX_rollback", status); session.setWasJTSTransactionInternallyStarted(false); // Only roll back if there is a transaction to roll back if ((canRollbackTransaction_impl(status)) && (getTransaction() != null)) { logTxTrace(session, "TX_rollingBackTxn", null); rollbackTransaction_impl(); } } catch (Exception exception) { throw TransactionException.errorRollingBackExternalTransaction(exception); } }
/** * INTERNAL: * Called after transaction is completed (committed or rolled back) */ public void afterTransaction(boolean committed, boolean isExternalTransaction) { if (!committed && isExternalTransaction) { // In case jts transaction was internally started but rolled back // directly by TransactionManager this flag may still be true during afterCompletion getParent().setWasJTSTransactionInternallyStarted(false); //bug#4699614 -- added a new life cycle status so we know if the external transaction was rolledback and we don't try to rollback again later setLifecycle(AfterExternalTransactionRolledBack); } if ((getMergeManager() != null) && (getMergeManager().getAcquiredLocks() != null) && (!getMergeManager().getAcquiredLocks().isEmpty())) { //may have unreleased cache locks because of a rollback... getParent().getIdentityMapAccessorInstance().getWriteLockManager().releaseAllAcquiredLocks(getMergeManager()); this.setMergeManager(null); } getParent().afterTransaction(committed, isExternalTransaction); }