HHH-6170 Offer ability to customize the default TransactionFactory implementation
Allow to customize implementation used if none is specified specifically by the user programmatically or via configuration
This commit is contained in:
parent
8a4b5ccbfc
commit
45ac70b03d
|
@ -379,6 +379,11 @@ public final class Environment {
|
||||||
* <tt>TransactionFactory</tt> implementor to use for creating <tt>Transaction</tt>s
|
* <tt>TransactionFactory</tt> implementor to use for creating <tt>Transaction</tt>s
|
||||||
*/
|
*/
|
||||||
public static final String TRANSACTION_STRATEGY = "hibernate.transaction.factory_class";
|
public static final String TRANSACTION_STRATEGY = "hibernate.transaction.factory_class";
|
||||||
|
/**
|
||||||
|
* If none is explicitly set, default <tt>TransactionFactory</tt> implementor
|
||||||
|
* to use for creating <tt>Transaction</tt>s
|
||||||
|
*/
|
||||||
|
public static final String DEFAULT_TRANSACTION_STRATEGY = "hibernate.transaction.default_factory_class";
|
||||||
/**
|
/**
|
||||||
* <tt>TransactionManagerLookup</tt> implementor to use for obtaining the <tt>TransactionManager</tt>
|
* <tt>TransactionManagerLookup</tt> implementor to use for obtaining the <tt>TransactionManager</tt>
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -55,6 +55,9 @@ public final class TransactionFactoryFactory {
|
||||||
*/
|
*/
|
||||||
public static TransactionFactory buildTransactionFactory(Properties transactionProps) throws HibernateException {
|
public static TransactionFactory buildTransactionFactory(Properties transactionProps) throws HibernateException {
|
||||||
String strategyClassName = transactionProps.getProperty( Environment.TRANSACTION_STRATEGY );
|
String strategyClassName = transactionProps.getProperty( Environment.TRANSACTION_STRATEGY );
|
||||||
|
if ( strategyClassName == null ) {
|
||||||
|
strategyClassName = transactionProps.getProperty( Environment.DEFAULT_TRANSACTION_STRATEGY );
|
||||||
|
}
|
||||||
if ( strategyClassName == null ) {
|
if ( strategyClassName == null ) {
|
||||||
log.info( "Using default transaction strategy (direct JDBC transactions)" );
|
log.info( "Using default transaction strategy (direct JDBC transactions)" );
|
||||||
return new JDBCTransactionFactory();
|
return new JDBCTransactionFactory();
|
||||||
|
|
|
@ -1284,10 +1284,7 @@ public class Ejb3Configuration implements Serializable, Referenceable {
|
||||||
preparedProperties.setProperty(
|
preparedProperties.setProperty(
|
||||||
Environment.TRANSACTION_STRATEGY, JoinableCMTTransactionFactory.class.getName()
|
Environment.TRANSACTION_STRATEGY, JoinableCMTTransactionFactory.class.getName()
|
||||||
);
|
);
|
||||||
}
|
} //else if RESOURCE_LOCAL, let the default being used.
|
||||||
else if ( ! hasTxStrategy && transactionType == PersistenceUnitTransactionType.RESOURCE_LOCAL ) {
|
|
||||||
preparedProperties.setProperty( Environment.TRANSACTION_STRATEGY, JDBCTransactionFactory.class.getName() );
|
|
||||||
}
|
|
||||||
if ( hasTxStrategy ) {
|
if ( hasTxStrategy ) {
|
||||||
log.warn(
|
log.warn(
|
||||||
"Overriding {} is dangerous, this might break the EJB3 specification implementation",
|
"Overriding {} is dangerous, this might break the EJB3 specification implementation",
|
||||||
|
|
Loading…
Reference in New Issue