HHH-6170 Offer ability to customize the default TransactionManagerLookup implementation

This commit is contained in:
Emmanuel Bernard 2011-04-29 17:53:18 -04:00
parent 45ac70b03d
commit 2706b688f2
2 changed files with 8 additions and 0 deletions

View File

@ -388,6 +388,11 @@ public final class Environment {
* <tt>TransactionManagerLookup</tt> implementor to use for obtaining the <tt>TransactionManager</tt>
*/
public static final String TRANSACTION_MANAGER_STRATEGY = "hibernate.transaction.manager_lookup_class";
/**
* If none is explicitly set, default <tt>TransactionManagerLookup</tt> implementor
* to use for obtaining the <tt>TransactionManager</tt>
*/
public static final String DEFAULT_TRANSACTION_MANAGER_STRATEGY = "hibernate.transaction.default_manager_lookup_class";
/**
* JNDI name of JTA <tt>UserTransaction</tt> object
*/

View File

@ -76,6 +76,9 @@ public final class TransactionManagerLookupFactory {
*/
public static TransactionManagerLookup getTransactionManagerLookup(Properties props) throws HibernateException {
String tmLookupClass = props.getProperty( Environment.TRANSACTION_MANAGER_STRATEGY );
if ( tmLookupClass == null ) {
tmLookupClass = props.getProperty( Environment.DEFAULT_TRANSACTION_MANAGER_STRATEGY );
}
if ( tmLookupClass == null ) {
log.info( "No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)" );
return null;