List of usage examples for org.hibernate ConnectionReleaseMode AFTER_TRANSACTION
ConnectionReleaseMode AFTER_TRANSACTION
To view the source code for org.hibernate ConnectionReleaseMode AFTER_TRANSACTION.
Click Source Link
From source file:com.googlecode.hibernate.audit.synchronization.AuditSynchronization.java
License:Open Source License
public void doBeforeTransactionCompletion(SessionImplementor session) { if (workUnits.size() == 0) { return;//from w w w. jav a2 s.c om } if (!isMarkedForRollback(auditedSession)) { try { if (FlushMode.isManualFlushMode(auditedSession.getFlushMode())) { Session temporarySession = null; try { temporarySession = ((Session) session).sessionWithOptions().transactionContext() .autoClose(false).connectionReleaseMode(ConnectionReleaseMode.AFTER_TRANSACTION) .openSession(); executeInSession(temporarySession); temporarySession.flush(); } finally { if (temporarySession != null) { temporarySession.close(); } } } else { auditedSession.flush(); executeInSession(auditedSession); } } catch (RuntimeException e) { if (log.isErrorEnabled()) { log.error("RuntimeException occurred in beforeCompletion, will rollback and re-throw exception", e); } rollback(); throw e; } } }
From source file:org.xerela.zap.hibernate.internal.ZTransactionFactory.java
License:Mozilla Public License
/** {@inheritDoc} */ public ConnectionReleaseMode getDefaultReleaseMode() { return ConnectionReleaseMode.AFTER_TRANSACTION; //AFTER_STATEMENT; }