Methods Summary |
---|
public void | afterNontransactionalQuery(boolean success)Called after executing a query outside the scope of
a Hibernate or JTA transaction
log.trace( "after autocommit" );
try {
// check to see if the connection is in auto-commit
// mode (no connection means aggressive connection
// release outside a JTA transaction context, so MUST
// be autocommit mode)
boolean isAutocommit = connectionManager.isAutoCommit();
connectionManager.afterTransaction();
if ( isAutocommit ) {
owner.afterTransactionCompletion(success, null);
}
}
catch (SQLException sqle) {
throw JDBCExceptionHelper.convert(
owner.getFactory().getSQLExceptionConverter(),
sqle,
"could not inspect JDBC autocommit mode"
);
}
|
public void | afterTransactionBegin(org.hibernate.Transaction tx)We cannot rely upon this method being called! It is only
called if we are using Hibernate Transaction API.
log.trace( "after transaction begin" );
owner.afterTransactionBegin(tx);
|
public void | afterTransactionCompletion(boolean success, org.hibernate.Transaction tx)
log.trace( "after transaction completion" );
if ( getFactory().getStatistics().isStatisticsEnabled() ) {
getFactory().getStatisticsImplementor().endTransaction(success);
}
connectionManager.afterTransaction();
isTransactionCallbackRegistered = false;
hibernateTransaction = null;
owner.afterTransactionCompletion(success, tx);
|
public void | beforeTransactionCompletion(org.hibernate.Transaction tx)
log.trace( "before transaction completion" );
owner.beforeTransactionCompletion(tx);
|
public java.sql.Connection | borrowConnection()
return connectionManager.borrowConnection();
|
public java.sql.Connection | connection()
if ( owner.isClosed() ) {
throw new SessionException( "Session is closed" );
}
return connectionManager.getConnection();
|
public void | connectionCleanedUp()
if ( !isTransactionCallbackRegistered ) {
afterTransactionCompletion( false, null );
// Note : success = false, because we don't know the outcome of the transaction
}
|
public void | connectionOpened()
if ( owner.getFactory().getStatistics().isStatisticsEnabled() ) {
owner.getFactory().getStatisticsImplementor().connect();
}
|
public static org.hibernate.jdbc.JDBCContext | deserialize(java.io.ObjectInputStream ois, org.hibernate.jdbc.JDBCContext$Context context, org.hibernate.Interceptor interceptor)Custom deserialization routine used during deserialization of a
Session/PersistenceContext for increased performance.
JDBCContext jdbcContext = new JDBCContext();
jdbcContext.owner = context;
jdbcContext.connectionManager = ConnectionManager.deserialize(
ois,
context.getFactory(),
interceptor,
context.getConnectionReleaseMode(),
jdbcContext
);
return jdbcContext;
|
public ConnectionManager | getConnectionManager()
return connectionManager;
|
public org.hibernate.engine.SessionFactoryImplementor | getFactory()
return owner.getFactory();
|
public org.hibernate.Transaction | getTransaction()
if (hibernateTransaction==null) {
hibernateTransaction = owner.getFactory().getSettings()
.getTransactionFactory()
.createTransaction( this, owner );
}
return hibernateTransaction;
|
public boolean | isTransactionInProgress()
return owner.getFactory().getSettings().getTransactionFactory()
.isTransactionInProgress( this, owner, hibernateTransaction );
|
private void | readObject(java.io.ObjectInputStream ois)
ois.defaultReadObject();
isTransactionCallbackRegistered = ois.readBoolean();
|
public boolean | registerCallbackIfNecessary()
if ( isTransactionCallbackRegistered ) {
return false;
}
else {
isTransactionCallbackRegistered = true;
return true;
}
|
public boolean | registerSynchronizationIfPossible()
if ( isTransactionCallbackRegistered ) {
// we already have a callback registered; either a local
// (org.hibernate.Transaction) transaction has accepted
// callback responsibilities, or we have previously
// registered a transaction synch.
return true;
}
boolean localCallbacksOnly = owner.getFactory().getSettings()
.getTransactionFactory()
.areCallbacksLocalToHibernateTransactions();
if ( localCallbacksOnly ) {
// the configured transaction-factory says it only supports
// local callback mode, so no sense attempting to register a
// JTA Synchronization
return false;
}
TransactionManager tm = owner.getFactory().getTransactionManager();
if ( tm == null ) {
// if there is no TM configured, we will not be able to access
// the javax.transaction.Transaction object in order to
// register a synch anyway.
return false;
}
else {
try {
if ( !isTransactionInProgress() ) {
log.trace( "TransactionFactory reported no active transaction; Synchronization not registered" );
return false;
}
else {
javax.transaction.Transaction tx = tm.getTransaction();
if ( JTAHelper.isMarkedForRollback( tx ) ) {
log.debug( "Transaction is marked for rollback; skipping Synchronization registration" );
return false;
}
else {
tx.registerSynchronization( new CacheSynchronization(owner, this, tx, null) );
isTransactionCallbackRegistered = true;
log.debug("successfully registered Synchronization");
return true;
}
}
}
catch( HibernateException e ) {
throw e;
}
catch (Exception e) {
throw new TransactionException( "could not register synchronization with JTA TransactionManager", e );
}
}
|
public void | serialize(java.io.ObjectOutputStream oos)Custom serialization routine used during serialization of a
Session/PersistenceContext for increased performance.
connectionManager.serialize( oos );
|
private void | writeObject(java.io.ObjectOutputStream oos)
// isTransactionCallbackRegistered denotes whether any Hibernate
// Transaction has registered as a callback against this
// JDBCContext; only one such callback is allowed. Directly
// serializing this value causes problems with JDBCTransaction,
// or really any Transaction impl where the callback is local
// to the Transaction instance itself, since that Transaction
// is not serialized along with the JDBCContext. Thus we
// handle that fact here explicitly...
oos.defaultWriteObject();
boolean deserHasCallbackRegistered = isTransactionCallbackRegistered
&& ! owner.getFactory().getSettings().getTransactionFactory()
.areCallbacksLocalToHibernateTransactions();
oos.writeBoolean( deserHasCallbackRegistered );
|