/** * PUBLIC: * Return the active unit of work for the current active external (JTS) transaction. * This should only be used with JTS and will return null if no external transaction exists. */ public oracle.toplink.essentials.sessions.UnitOfWork getActiveUnitOfWork() { if (hasExternalTransactionController()) { return getExternalTransactionController().getActiveUnitOfWork(); } /* Steven Vo: CR# 2517 Get from the server session since the external transaction controller could be null out from the client session by TL WebLogic 5.1 to provide non-jts transaction operations */ if (isClientSession()) { return ((oracle.toplink.essentials.threetier.ClientSession)this).getParent().getActiveUnitOfWork(); } return null; }
/** * INTERNAL: * Attempts to begin an external transaction. * Returns true only in one case - * extenal transaction has been internally started during this method call: * wasJTSTransactionInternallyStarted()==false in the beginning of this method and * wasJTSTransactionInternallyStarted()==true in the end of this method. */ public boolean beginExternalTransaction() { boolean externalTransactionHasBegun = false; if (hasExternalTransactionController() && !wasJTSTransactionInternallyStarted()) { try { getExternalTransactionController().beginTransaction(this); } catch (RuntimeException exception) { handleException(exception); } if (wasJTSTransactionInternallyStarted()) { externalTransactionHasBegun = true; log(SessionLog.FINER, SessionLog.TRANSACTION, "external_transaction_has_begun_internally"); } } return externalTransactionHasBegun; }
/** * PROTECTED: * Attempts to rollback the running internally started external transaction. * Returns true only in one case - * extenal transaction has been internally rolled back during this method call: * wasJTSTransactionInternallyStarted()==true in the beginning of this method and * wasJTSTransactionInternallyStarted()==false in the end of this method. */ protected boolean rollbackExternalTransaction() { boolean externalTransactionHasRolledBack = false; if (hasExternalTransactionController() && wasJTSTransactionInternallyStarted()) { try { getExternalTransactionController().rollbackTransaction(this); } catch (RuntimeException exception) { handleException(exception); } if (!wasJTSTransactionInternallyStarted()) { externalTransactionHasRolledBack = true; log(SessionLog.FINER, SessionLog.TRANSACTION, "external_transaction_has_rolled_back_internally"); } } return externalTransactionHasRolledBack; }
/** * INTERNAL: * Attempts to commit the running internally started external transaction. * Returns true only in one case - * extenal transaction has been internally committed during this method call: * wasJTSTransactionInternallyStarted()==true in the beginning of this method and * wasJTSTransactionInternallyStarted()==false in the end of this method. */ public boolean commitExternalTransaction() { boolean externalTransactionHasCommitted = false; if (hasExternalTransactionController() && wasJTSTransactionInternallyStarted()) { try { getExternalTransactionController().commitTransaction(this); } catch (RuntimeException exception) { handleException(exception); } if (!wasJTSTransactionInternallyStarted()) { externalTransactionHasCommitted = true; log(SessionLog.FINER, SessionLog.TRANSACTION, "external_transaction_has_committed_internally"); } } return externalTransactionHasCommitted; }
/** * INTERNAL: * rollbackTransaction() with a twist for external transactions. * <p> * writeChanges() is called outside the JTA beforeCompletion(), so the * accompanying exception won't propogate up and cause a rollback by itself. * <p> * Instead must mark the transaction for rollback only here. * <p> * If internally started external transaction or no external transaction * can still rollback normally. * @param intendedToCommitTransaction whether we were inside a commit or just trying to * write out changes early. */ protected void rollbackTransaction(boolean intendedToCommitTransaction) throws DatabaseException { if (!intendedToCommitTransaction && getParent().hasExternalTransactionController() && !getParent().wasJTSTransactionInternallyStarted()) { getParent().getExternalTransactionController().markTransactionForRollback(); } rollbackTransaction(); }
/** * INTERNAL: * Register this UnitOfWork against an external transaction controller */ public void registerWithTransactionIfRequired() { if (getParent().hasExternalTransactionController() && ! isSynchronized()) { boolean hasAlreadyStarted = getParent().wasJTSTransactionInternallyStarted(); getParent().getExternalTransactionController().registerSynchronizationListener(this, getParent()); // CR#2998 - registerSynchronizationListener may toggle the wasJTSTransactionInternallyStarted // flag. As a result, we must compare the states and if the state is changed, then we must set the // setWasTransactionBegunPrematurely flag to ensure that we handle the transaction depth count // appropriately if (!hasAlreadyStarted && getParent().wasJTSTransactionInternallyStarted()) { // registerSynchronizationListener caused beginTransaction() called // and an external transaction internally started. this.setWasTransactionBegunPrematurely(true); } } }
if (session.getExternalTransactionController() == null) { setIsInTransaction(false); if ((getDatasourceConnection() != null) && usesExternalConnectionPooling()) {
if (session.getExternalTransactionController() == null) { setIsInTransaction(false); if ((getDatasourceConnection() != null) && usesExternalConnectionPooling()) {