Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
A Hibernate org.hibernate.transaction.JTATransactionFactory implementation that avoids using JNDI for lookups.
package my.project.hibernate;
import javax.transaction.UserTransaction;
import org.hibernate.transaction.JTATransactionFactory;
* A Hibernate {@link JTATransactionFactory} implementation that avoids using JNDI for lookups. You must set the
* {@link UserTransaction} on this bean with #setUserTransaction(UserTransaction)} before using it.
public class LocalJtaTransactionFactory extends JTATransactionFactory {
private static volatile UserTransaction userTransaction;
public synchronized void setUserTransaction(UserTransaction userTransaction) {
LocalJtaTransactionFactory.userTransaction = userTransaction;
protected UserTransaction getUserTransaction() {
return userTransaction;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment