org.hibernate.resource.transaction.spi.TransactionCoordinator Java Examples

The following examples show how to use org.hibernate.resource.transaction.spi.TransactionCoordinator. 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: BaseCoreFunctionalTestCase.java    From google-cloud-spanner-hibernate with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void completeStrayTransaction() {
  if ( session == null ) {
    // nothing to do
    return;
  }

  if ( ( (SessionImplementor) session ).isClosed() ) {
    // nothing to do
    return;
  }

  if ( !session.isConnected() ) {
    // nothing to do
    return;
  }

  final TransactionCoordinator.TransactionDriver tdc =
      ( (SessionImplementor) session ).getTransactionCoordinator().getTransactionDriverControl();

  if ( tdc.getStatus().canRollback() ) {
    session.getTransaction().rollback();
  }
  session.close();
}
 
Example #2
Source File: TransactionImpl.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
public TransactionImpl(
		TransactionCoordinator transactionCoordinator,
		ExceptionConverter exceptionConverter,
		AbstractSharedSessionContract session) {
	this.transactionCoordinator = transactionCoordinator;
	this.exceptionConverter = exceptionConverter;
	this.jpaCompliance = session.getFactory().getSessionFactoryOptions().getJpaCompliance();
	this.session = session;

	if ( session.isOpen() && transactionCoordinator.isActive() ) {
		this.transactionDriverControl = transactionCoordinator.getTransactionDriverControl();
	}
	else {
		LOG.debug( "TransactionImpl created on closed Session/EntityManager" );
	}

	if ( LOG.isDebugEnabled() ) {
		LOG.debugf(
				"On TransactionImpl creation, JpaCompliance#isJpaTransactionComplianceEnabled == %s",
				jpaCompliance.isJpaTransactionComplianceEnabled()
		);
	}
}
 
Example #3
Source File: JdbcResourceLocalTransactionCoordinatorBuilderImpl.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public TransactionCoordinator buildTransactionCoordinator(TransactionCoordinatorOwner owner, Options options) {
	if ( owner instanceof JdbcResourceTransactionAccess ) {
		return new JdbcResourceLocalTransactionCoordinatorImpl(
				this,
				owner,
				(JdbcResourceTransactionAccess) owner
		);
	}

	throw new HibernateException(
			"Could not determine ResourceLocalTransactionAccess to use in building TransactionCoordinator"
	);
}
 
Example #4
Source File: JtaTransactionCoordinatorBuilderImpl.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public TransactionCoordinator buildTransactionCoordinator(TransactionCoordinatorOwner owner, Options options) {
	return new JtaTransactionCoordinatorImpl(
			this,
			owner,
			options.shouldAutoJoinTransaction()
	);
}
 
Example #5
Source File: SessionImpl.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void addSharedSessionTransactionObserver(TransactionCoordinator transactionCoordinator) {
	this.transactionObserver = new TransactionObserver() {
		@Override
		public void afterBegin() {
		}

		@Override
		public void beforeCompletion() {
			if ( isOpen() && getHibernateFlushMode() !=  FlushMode.MANUAL ) {
				managedFlush();
			}
			actionQueue.beforeTransactionCompletion();
			try {
				getInterceptor().beforeTransactionCompletion( getCurrentTransaction() );
			}
			catch (Throwable t) {
				log.exceptionInBeforeTransactionCompletionInterceptor( t );
			}
		}

		@Override
		public void afterCompletion(boolean successful, boolean delayed) {
			afterTransactionCompletion( successful, delayed );
			if ( !isClosed() && autoClose ) {
				managedClose();
			}
		}
	};
	transactionCoordinator.addObserver(transactionObserver);
}
 
Example #6
Source File: SessionDelegatorBaseImpl.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public TransactionCoordinator getTransactionCoordinator() {
	return delegate.getTransactionCoordinator();
}
 
Example #7
Source File: SessionImpl.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public TransactionCoordinator getTransactionCoordinator() {
	return shareTransactionContext ? session.getTransactionCoordinator() : null;
}
 
Example #8
Source File: SessionImpl.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected void removeSharedSessionTransactionObserver(TransactionCoordinator transactionCoordinator) {
	super.removeSharedSessionTransactionObserver( transactionCoordinator );
	transactionCoordinator.removeObserver( transactionObserver );
}
 
Example #9
Source File: AbstractSharedSessionContract.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
protected void addSharedSessionTransactionObserver(TransactionCoordinator transactionCoordinator) {
}
 
Example #10
Source File: AbstractSharedSessionContract.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
protected void removeSharedSessionTransactionObserver(TransactionCoordinator transactionCoordinator) {
	transactionCoordinator.invalidate();
}
 
Example #11
Source File: AbstractSharedSessionContract.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public TransactionCoordinator getTransactionCoordinator() {
	return transactionCoordinator;
}
 
Example #12
Source File: AbstractProxySharedSessionContractImplementor.java    From jadira with Apache License 2.0 4 votes vote down vote up
@Override
public TransactionCoordinator getTransactionCoordinator() {
	return target.getTransactionCoordinator();
}
 
Example #13
Source File: JdbcSessionOwner.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Obtain the builder for TransactionCoordinator instances
 *
 * @return The TransactionCoordinatorBuilder
 */
TransactionCoordinator getTransactionCoordinator();
 
Example #14
Source File: SharedSessionCreationOptions.java    From lams with GNU General Public License v2.0 votes vote down vote up
TransactionCoordinator getTransactionCoordinator();