Created
January 17, 2013 13:21
-
-
Save teabot/4555896 to your computer and use it in GitHub Desktop.
A Hibernate org.hibernate.transaction.JTATransactionFactory implementation that avoids using JNDI for lookups.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
@Override | |
protected UserTransaction getUserTransaction() { | |
return userTransaction; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment