* This method executes within the transaction context of the caller of
* transaction.commit(), or in the case of container-managed transactions,
* in the context of the method for which the Container started the transaction.
*/
public void beforeCompletion() {
UnitOfWorkImpl uow = getUnitOfWork();
// it's a purely sequencing listener - nothing to do in beforeCompletion.
if(unitOfWork == null) {
return;
}
try {
Object status = getTransactionController().getTransactionStatus();
getTransactionController().logTxStateTrace(uow, "TX_beforeCompletion", status);
//CR# 3452053
session.startOperationProfile(SessionProfiler.JtsBeforeCompletion);
// In case jts transaction was internally started but completed
// directly by TransactionManager this flag is still set to true.
getSession().setWasJTSTransactionInternallyStarted(false);
// If the uow is not active then somebody somewhere messed up
if (!uow.isActive()) {
throw TransactionException.inactiveUnitOfWork(uow);
}
// Bail out if we don't think we should actually issue the SQL
if (!getTransactionController().canIssueSQLToDatabase_impl(status)) {
// Must force concurrency mgrs active thread if in nested transaction
if (getSession().isInTransaction()) {
getSession().getTransactionMutex().setActiveThread(Thread.currentThread());
if(getUnitOfWork().wasTransactionBegunPrematurely()) {
getUnitOfWork().setWasTransactionBegunPrematurely(false);
}
getSession().rollbackTransaction();
}
getSession().releaseJTSConnection();
return;
}
// Must force concurrency mgrs active thread if in nested transaction
if (getSession().isInTransaction()) {
getSession().getTransactionMutex().setActiveThread(Thread.currentThread());
}
// If sequencing callback for this transaction will be required
// in case it doesn't already exist it will be created on this very listener
// avoiding adding more listeners while processing a listener.
if(getTransactionController().isSequencingCallbackRequired()) {
getTransactionController().currentlyProcessedListeners.put(getTransactionKey(), this);
}
// Send the SQL to the DB
uow.issueSQLbeforeCompletion();
// Fix up our merge state in the unit of work and the session
uow.setPendingMerge();
} catch (RuntimeException exception) {
// Log the exception if it has not already been logged, or is a non-EclipseLink exception
if (!(exception instanceof EclipseLinkException && ((EclipseLinkException)exception).hasBeenLogged())) {
uow.logThrowable(SessionLog.WARNING, SessionLog.TRANSACTION, exception);
}
// Handle the exception according to transaction manager requirements
handleException(exception);
} finally {