org.hibernate.jdbc.JDBCContext Java Examples

The following examples show how to use org.hibernate.jdbc.JDBCContext. 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
Source File: JTATransaction.java    From cacheonix-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
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 #2
Source File: JDBCTransactionFactory.java    From cacheonix-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
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 #3
Source File: CMTTransactionFactory.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
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 #4
Source File: DummyJTAStyleTransationFactory.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
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 #5
Source File: SessionImpl.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * 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 #6
Source File: CacheSynchronization.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
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
Source File: SpringTransactionFactory.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean isTransactionInProgress(
		JDBCContext jdbcContext, Context transactionContext, Transaction transaction) {

	return (transaction != null && transaction.isActive()) ||
			TransactionSynchronizationManager.isActualTransactionActive();
}
 
Example #8
Source File: SpringTransactionFactory.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isTransactionInProgress(
		JDBCContext jdbcContext, Context transactionContext, Transaction transaction) {

	return (transaction != null && transaction.isActive()) ||
			TransactionSynchronizationManager.isActualTransactionActive();
}
 
Example #9
Source File: JDBCTransaction.java    From cacheonix-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public JDBCTransaction(JDBCContext jdbcContext, TransactionFactory.Context transactionContext) {
	this.jdbcContext = jdbcContext;
	this.transactionContext = transactionContext;
}
 
Example #10
Source File: DummyJTAStyleTransationFactory.java    From cacheonix-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public Transaction createTransaction(
		JDBCContext jdbcContext,
		Context context) throws HibernateException {
	return new DummyTransactionAdapter();
}
 
Example #11
Source File: StatelessSessionImpl.java    From cacheonix-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public JDBCContext getJDBCContext() {
	return jdbcContext;
}
 
Example #12
Source File: StatelessSessionImpl.java    From cacheonix-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
StatelessSessionImpl(Connection connection, SessionFactoryImpl factory) {
	super( factory );
	this.jdbcContext = new JDBCContext( this, connection, EmptyInterceptor.INSTANCE );
}
 
Example #13
Source File: SessionImpl.java    From cacheonix-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * 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 #14
Source File: SessionImpl.java    From cacheonix-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public JDBCContext getJDBCContext() {
	errorIfClosed();
	checkTransactionSynchStatus();
	return jdbcContext;
}
 
Example #15
Source File: SpringTransactionFactory.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
public Transaction createTransaction(JDBCContext jdbcContext, Context transactionContext) {
	return new JDBCTransaction(jdbcContext, transactionContext);
}
 
Example #16
Source File: CMTTransaction.java    From cacheonix-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public CMTTransaction(JDBCContext jdbcContext, TransactionFactory.Context transactionContext) {
	this.jdbcContext = jdbcContext;
	this.transactionContext = transactionContext;
}
 
Example #17
Source File: SpringTransactionFactory.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Transaction createTransaction(JDBCContext jdbcContext, Context transactionContext) {
	return new JDBCTransaction(jdbcContext, transactionContext);
}
 
Example #18
Source File: CMTTransactionFactory.java    From cacheonix-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public Transaction createTransaction(JDBCContext jdbcContext, Context transactionContext)
throws HibernateException {
	return new CMTTransaction(jdbcContext, transactionContext);
}
 
Example #19
Source File: JDBCTransactionFactory.java    From cacheonix-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public Transaction createTransaction(JDBCContext jdbcContext, Context transactionContext)
throws HibernateException {
	return new JDBCTransaction( jdbcContext, transactionContext );
}
 
Example #20
Source File: JTATransactionFactory.java    From cacheonix-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public Transaction createTransaction(JDBCContext jdbcContext, Context transactionContext)
throws HibernateException {
	return new JTATransaction(context, utName, jdbcContext, transactionContext);
}
 
Example #21
Source File: TransactionFactory.java    From cacheonix-core with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * 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 #22
Source File: TransactionFactory.java    From cacheonix-core with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * 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 #23
Source File: SessionImplementor.java    From cacheonix-core with GNU Lesser General Public License v2.1 votes vote down vote up
public JDBCContext getJDBCContext();