Methods Summary |
---|
private org.hibernate.context.JTASessionContext$CleanupSynch | buildCleanupSynch(javax.transaction.Transaction txn)
return new CleanupSynch( txn, this );
|
protected org.hibernate.classic.Session | buildOrObtainSession()Strictly provided for subclassing purposes; specifically to allow long-session
support.
This implementation always just opens a new session.
return factory.openSession(
null,
isAutoFlushEnabled(),
isAutoCloseEnabled(),
getConnectionReleaseMode()
);
|
public org.hibernate.classic.Session | currentSession()
TransactionManager transactionManager = factory.getTransactionManager();
if ( transactionManager == null ) {
throw new HibernateException( "No TransactionManagerLookup specified" );
}
Transaction txn = null;
try {
txn = transactionManager.getTransaction();
if ( txn == null ) {
throw new HibernateException( "Unable to locate current JTA transaction" );
}
if ( !JTAHelper.isInProgress( txn.getStatus() ) ) {
// We could register the session against the transaction even though it is
// not started, but we'd have no guarentee of ever getting the map
// entries cleaned up (aside from spawning threads).
throw new HibernateException( "Current transaction is not in progress" );
}
}
catch ( HibernateException e ) {
throw e;
}
catch ( Throwable t ) {
throw new HibernateException( "Problem locating/validating JTA transaction", t );
}
Session currentSession = ( Session ) currentSessionMap.get( txn );
if ( currentSession == null ) {
currentSession = buildOrObtainSession();
try {
txn.registerSynchronization( buildCleanupSynch( txn ) );
}
catch ( Throwable t ) {
try {
currentSession.close();
}
catch ( Throwable ignore ) {
log.debug( "Unable to release generated current-session on failed synch registration", ignore );
}
throw new HibernateException( "Unable to register cleanup Synchronization with TransactionManager" );
}
currentSessionMap.put( txn, currentSession );
}
return currentSession;
|
protected org.hibernate.ConnectionReleaseMode | getConnectionReleaseMode()Mainly for subclass usage. This impl always returns after_statement.
return ConnectionReleaseMode.AFTER_STATEMENT;
|
protected boolean | isAutoCloseEnabled()Mainly for subclass usage. This impl always returns true.
return true;
|
protected boolean | isAutoFlushEnabled()Mainly for subclass usage. This impl always returns true.
return true;
|