CacheSynchronizationpublic final class CacheSynchronization extends Object implements Synchronization
Fields Summary |
---|
private static final Log | log | private final TransactionFactory.Context | ctx | private org.hibernate.jdbc.JDBCContext | jdbcContext | private final Transaction | transaction | private final org.hibernate.Transaction | hibernateTransaction |
Methods Summary |
---|
public void | afterCompletion(int status)
if ( log.isTraceEnabled() ) {
log.trace("transaction after completion callback, status: " + status);
}
try {
jdbcContext.afterTransactionCompletion(status==Status.STATUS_COMMITTED, hibernateTransaction);
}
finally {
if ( ctx.shouldAutoClose() && !ctx.isClosed() ) {
log.trace("automatically closing session");
ctx.managedClose();
}
}
| public void | beforeCompletion()
log.trace("transaction before completion callback");
boolean flush;
try {
flush = !ctx.isFlushModeNever() &&
ctx.isFlushBeforeCompletionEnabled() &&
!JTAHelper.isRollback( transaction.getStatus() );
//actually, this last test is probably unnecessary, since
//beforeCompletion() doesn't get called during rollback
}
catch (SystemException se) {
log.error("could not determine transaction status", se);
setRollbackOnly();
throw new TransactionException("could not determine transaction status in beforeCompletion()", se);
}
try {
if (flush) {
log.trace("automatically flushing session");
ctx.managedFlush();
}
}
catch (RuntimeException re) {
setRollbackOnly();
throw re;
}
finally {
jdbcContext.beforeTransactionCompletion(hibernateTransaction);
}
| private void | setRollbackOnly()
try {
transaction.setRollbackOnly();
}
catch (SystemException se) {
log.error("could not set transaction to rollback only", se);
}
| public java.lang.String | toString()
return CacheSynchronization.class.getName();
|
|