Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * Hibernate OGM, Domain model persistence for NoSQL datastores
  *
  * License: GNU Lesser General Public License (LGPL), version 2.1 or later
  * See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
  */
 package org.hibernate.ogm.transaction.impl;
 
TransactionFactory allowing to choose between JTA transactions retrieved from the TransactionManager or to emulate transactions via EmulatedLocalTransaction. The latter is not a proper Transaction implementation, but only used to make sure that the appropriate flush events are triggered at commit time. This transaction can be useful in the case where the configured transaction type is resource local and the data store does not implement transactions (eg MongoDB).

Author(s):
Emmanuel Bernard <emmanuel@hibernate.org>
public class OgmTransactionFactory implements TransactionFactory {
	private final boolean emulateTransaction;
	public OgmTransactionFactory(boolean emulateTransaction) {
		this. = emulateTransaction;
	}
		if (  ) {
			return new EmulatedLocalTransactioncoordinator );
		}
		else {
			return new JTATransactioncoordinator );
		}
	}
	public boolean canBeDriver() {
		return true;
	}
	public boolean compatibleWithJtaSynchronization() {
	}
	public boolean isJoinableJtaTransaction(TransactionCoordinator transactionCoordinator,
			TransactionImplementor transaction) {
		if (  ) {
			return false;
		}
		try {
			final JtaPlatform jtaPlatform = transactionCoordinator
			if ( jtaPlatform == null ) {
				throw new TransactionException"Unable to check transaction status" );
			}
			if ( jtaPlatform.retrieveTransactionManager() != null ) {
				return JtaStatusHelper.isActivejtaPlatform.retrieveTransactionManager().getStatus() );
			}
			else {
				final UserTransaction ut = jtaPlatform.retrieveUserTransaction();
				return ut != null && JtaStatusHelper.isActiveut );
			}
		}
		catch ( SystemException se ) {
			throw new TransactionException"Unable to check transaction status"se );
		}
	}
	}
New to GrepCode? Check out our FAQ X