Java Code Examples for org.hibernate.jdbc.JDBCContext

The following examples show how to use org.hibernate.jdbc.JDBCContext. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
public boolean isTransactionInProgress(
			JDBCContext jdbcContext,
	        Context transactionContext,
	        Transaction transaction) {
//		try {
//			// for JDBC-based transactions, we only want to return true
//			// here if we (this transaction) are managing the transaction
//			return transaction != null &&
//			       transaction.isActive() &&
//			       !jdbcContext.getConnectionManager().isAutoCommit();
//		}
//		catch ( SQLException e ) {
//			// assume we are in auto-commit!
//			return false;
//		}
		return transaction != null && transaction.isActive();
	}
 
Example 2
public JTATransaction(
		InitialContext context, 
		String utName, 
		JDBCContext jdbcContext, 
		TransactionFactory.Context transactionContext
) {
	this.jdbcContext = jdbcContext;
	this.transactionContext = transactionContext;

	log.debug("Looking for UserTransaction under: " + utName);
	
	try {
		ut = (UserTransaction) context.lookup(utName);
	}
	catch (NamingException ne) {
		log.error("Could not find UserTransaction in JNDI", ne);
		throw new TransactionException("Could not find UserTransaction in JNDI: ", ne);
	}
	if (ut==null) {
		throw new AssertionFailure("A naming service lookup returned null");
	}

	log.debug("Obtained UserTransaction");
}
 
Example 3
@Override
public boolean isTransactionInProgress(
		JDBCContext jdbcContext, Context transactionContext, Transaction transaction) {

	return (transaction != null && transaction.isActive()) ||
			TransactionSynchronizationManager.isActualTransactionActive();
}
 
Example 4
@Override
public boolean isTransactionInProgress(
		JDBCContext jdbcContext, Context transactionContext, Transaction transaction) {

	return (transaction != null && transaction.isActive()) ||
			TransactionSynchronizationManager.isActualTransactionActive();
}
 
Example 5
public boolean isTransactionInProgress(
		JDBCContext jdbcContext,
        Context transactionContext,
        Transaction transaction) {
	try {
		return JTAHelper.isTransactionInProgress(
				transactionContext.getFactory().getTransactionManager().getTransaction()
		);
	}
	catch( SystemException se ) {
		throw new TransactionException( "Unable to check transaction status", se );
	}

}
 
Example 6
public CacheSynchronization(
		TransactionFactory.Context ctx, 
		JDBCContext jdbcContext, 
		Transaction transaction, 
		org.hibernate.Transaction tx
) {
	this.ctx = ctx;
	this.jdbcContext = jdbcContext;
	this.transaction = transaction;
	this.hibernateTransaction = tx;
}
 
Example 7
/**
 * Constructor used for openSession(...) processing, as well as construction
 * of sessions for getCurrentSession().
 *
 * @param connection The user-supplied connection to use for this session.
 * @param factory The factory from which this session was obtained
 * @param autoclose NOT USED
 * @param timestamp The timestamp for this session
 * @param interceptor The interceptor to be applied to this session
 * @param entityMode The entity-mode for this session
 * @param flushBeforeCompletionEnabled Should we auto flush before completion of transaction
 * @param autoCloseSessionEnabled Should we auto close after completion of transaction
 * @param connectionReleaseMode The mode by which we should release JDBC connections.
 */
SessionImpl(
		final Connection connection,
		final SessionFactoryImpl factory,
		final boolean autoclose,
		final long timestamp,
		final Interceptor interceptor,
		final EntityMode entityMode,
		final boolean flushBeforeCompletionEnabled,
		final boolean autoCloseSessionEnabled,
		final ConnectionReleaseMode connectionReleaseMode) {
	super( factory );
	this.rootSession = null;
	this.timestamp = timestamp;
	this.entityMode = entityMode;
	this.interceptor = interceptor;
	this.listeners = factory.getEventListeners();
	this.actionQueue = new ActionQueue( this );
	this.persistenceContext = new StatefulPersistenceContext( this );
	this.flushBeforeCompletionEnabled = flushBeforeCompletionEnabled;
	this.autoCloseSessionEnabled = autoCloseSessionEnabled;
	this.connectionReleaseMode = connectionReleaseMode;
	this.jdbcContext = new JDBCContext( this, connection, interceptor );

	if ( factory.getStatistics().isStatisticsEnabled() ) {
		factory.getStatisticsImplementor().openSession();
	}

	if ( log.isDebugEnabled() ) {
		log.debug( "opened session at timestamp: " + timestamp );
	}
}
 
Example 8
public boolean isTransactionInProgress(
		JDBCContext jdbcContext,
		Context transactionContext,
		Transaction transaction) {
	try {
		return JTAHelper.isTransactionInProgress( DummyTransactionManager.INSTANCE.getCurrent() )
		       && ! JTAHelper.isMarkedForRollback( DummyTransactionManager.INSTANCE.getCurrent() );
	}
	catch( SystemException e ) {
		throw new HibernateException( e );
	}
}
 
Example 9
@Override
public Transaction createTransaction(JDBCContext jdbcContext, Context transactionContext) {
	return new JDBCTransaction(jdbcContext, transactionContext);
}
 
Example 10
@Override
public Transaction createTransaction(JDBCContext jdbcContext, Context transactionContext) {
	return new JDBCTransaction(jdbcContext, transactionContext);
}
 
Example 11
public CMTTransaction(JDBCContext jdbcContext, TransactionFactory.Context transactionContext) {
	this.jdbcContext = jdbcContext;
	this.transactionContext = transactionContext;
}
 
Example 12
public Transaction createTransaction(JDBCContext jdbcContext, Context transactionContext)
throws HibernateException {
	return new JTATransaction(context, utName, jdbcContext, transactionContext);
}
 
Example 13
public Transaction createTransaction(JDBCContext jdbcContext, Context transactionContext)
throws HibernateException {
	return new JDBCTransaction( jdbcContext, transactionContext );
}
 
Example 14
public Transaction createTransaction(JDBCContext jdbcContext, Context transactionContext)
throws HibernateException {
	return new CMTTransaction(jdbcContext, transactionContext);
}
 
Example 15
public JDBCTransaction(JDBCContext jdbcContext, TransactionFactory.Context transactionContext) {
	this.jdbcContext = jdbcContext;
	this.transactionContext = transactionContext;
}
 
Example 16
public JDBCContext getJDBCContext() {
	errorIfClosed();
	checkTransactionSynchStatus();
	return jdbcContext;
}
 
Example 17
/**
 * Used by JDK serialization...
 *
 * @param ois The input stream from which we are being read...
 * @throws IOException Indicates a general IO stream exception
 * @throws ClassNotFoundException Indicates a class resolution issue
 */
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
	log.trace( "deserializing session" );

	boolean isRootSession = ois.readBoolean();
	connectionReleaseMode = ConnectionReleaseMode.parse( ( String ) ois.readObject() );
	entityMode = EntityMode.parse( ( String ) ois.readObject() );
	autoClear = ois.readBoolean();
	flushMode = FlushMode.parse( ( String ) ois.readObject() );
	cacheMode = CacheMode.parse( ( String ) ois.readObject() );
	flushBeforeCompletionEnabled = ois.readBoolean();
	autoCloseSessionEnabled = ois.readBoolean();
	fetchProfile = ( String ) ois.readObject();
	interceptor = ( Interceptor ) ois.readObject();

	factory = SessionFactoryImpl.deserialize( ois );
	listeners = factory.getEventListeners();

	if ( isRootSession ) {
		jdbcContext = JDBCContext.deserialize( ois, this, interceptor );
	}

	persistenceContext = StatefulPersistenceContext.deserialize( ois, this );
	actionQueue = ActionQueue.deserialize( ois, this );

	enabledFilters = ( Map ) ois.readObject();
	childSessionsByEntityMode = ( Map ) ois.readObject();

	Iterator iter = enabledFilters.values().iterator();
	while ( iter.hasNext() ) {
		( ( FilterImpl ) iter.next() ).afterDeserialize(factory);
	}

	if ( isRootSession && childSessionsByEntityMode != null ) {
		iter = childSessionsByEntityMode.values().iterator();
		while ( iter.hasNext() ) {
			final SessionImpl child = ( ( SessionImpl ) iter.next() );
			child.rootSession = this;
			child.jdbcContext = this.jdbcContext;
		}
	}
}
 
Example 18
StatelessSessionImpl(Connection connection, SessionFactoryImpl factory) {
	super( factory );
	this.jdbcContext = new JDBCContext( this, connection, EmptyInterceptor.INSTANCE );
}
 
Example 19
public JDBCContext getJDBCContext() {
	return jdbcContext;
}
 
Example 20
public Transaction createTransaction(
		JDBCContext jdbcContext,
		Context context) throws HibernateException {
	return new DummyTransactionAdapter();
}
 
Example 21
/**
 * Begin a transaction and return the associated <tt>Transaction</tt> instance.
 *
 * @param jdbcContext  The jdbc context to which the transaction belongs
 * @param context The contract regarding the context in which this transaction will operate.
 * @return Transaction
 * @throws HibernateException
 */
public Transaction createTransaction(JDBCContext jdbcContext, Context context) throws HibernateException;
 
Example 22
/**
 * Determine whether an underlying transaction is in progress.
 * <p/>
 * Mainly this is used in determining whether to register a
 * synchronization as well as whether or not to circumvent
 * auto flushing outside transactions.
 *
 * @param jdbcContext
 * @param transactionContext
 * @param transaction
 * @return true if an underlying transaction is know to be in effect.
 */
public boolean isTransactionInProgress(JDBCContext jdbcContext, Context transactionContext, Transaction transaction);
 
Example 23
public JDBCContext getJDBCContext();