Skip to content

Instantly share code, notes, and snippets.

@sebersole
Created August 29, 2011 22:55
Show Gist options
  • Save sebersole/1179642 to your computer and use it in GitHub Desktop.
Save sebersole/1179642 to your computer and use it in GitHub Desktop.
public void beforeCompletion() {
LOG.trace("Transaction before completion callback");
boolean flush;
try {
final int status = transactionCoordinator
.getTransactionContext()
.getTransactionEnvironment()
.getJtaPlatform()
.getCurrentStatus();
flush = managedFlushChecker.shouldDoManagedFlush( transactionCoordinator, status );
}
catch ( SystemException se ) {
setRollbackOnly();
throw exceptionMapper.mapStatusCheckFailure( "could not determine transaction status in beforeCompletion()", se );
}
try {
if ( flush ) {
LOG.trace("Automatically flushing session");
transactionCoordinator.getTransactionContext().managedFlush();
}
}
catch ( RuntimeException re ) {
setRollbackOnly();
throw exceptionMapper.mapManagedFlushFailure( "error during managed flush", re );
}
finally {
try {
transactionCoordinator.sendBeforeTransactionCompletionNotifications( null );
transactionCoordinator.getTransactionContext().beforeTransactionCompletion( null );
}
catch ( RuntimeException re ) {
setRollbackOnly();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment