Where did the org.hibernate.transaction.JDBCTransactionFactory class migrate to Hibernate 5?

I am currently working on a project to upgrade from Hibernate 3.x to 5.x. Currently one of the properties in the hibernate xml config is this:

<property name="hibernate.transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>

      

In Hibernate 5, this specific class defined above and also the org.hibernate.transaction package does not seem to exist. This class is available in version 3.x ( https://docs.jboss.org/hibernate/envers/3.6/javadocs/org/hibernate/transaction/JDBCTransactionFactory.html ). There is no such class for Hibernate 5 api docs ( https://docs.jboss.org/hibernate/orm/5.0/javadocs/ )

Has Hibernate 5 dropped this particular package along with all of its classes? I checked all the required Hibernate 5 jars but couldn't find this org.hibernate.transaction.JDBCTransactionFactory class anywhere. What could be a suitable replacement for this class in Hibernate 5 configuration?

I've had limited success with googling so any answers would be appreciated!

+3


source to share


2 answers


So, after further research, I found that SPI transactions in Hibernate 5 have undergone a major change!

The corresponding property should be:

<property name="hibernate.transaction.coordinator_class">org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl</property>

      

or use a short name:



<property name="hibernate.transaction.coordinator_class">jdbc</property>

      

From https://github.com/hibernate/hibernate-orm/blob/5.0/migration-guide.adoc#transactions

The SPI transaction went through a major redesign as part of 5.0. From a user perspective, this usually only appears in terms of configuration. In the past, applications would work with different backend transaction strategies directly through the org.hibernate.Transaction API. In 5.0, a level of indirection was added here. The org.hibernate.Transaction API implementation is always the same. On the backend, org.hibernate.Transaction impl negotiates with org.hibernate.resource.transaction.TransactionCoordinator, which represents the "transactional context" for a given session according to the backend's transaction strategy. Users usually don't need to care about the difference.

A change is noted here as it might affect the bootstrap configuration. If the application previously indicated and referred to hibernate.transaction.factory_class org.hibernate.engine.transaction.spi.TransactionFactory FQN, with 5.0, a new contract - org.hibernate.resource.transaction.TransactionCoordinatorBuilder and specified using hibernate.transaction.coordinator_class . For more information, see the org.hibernate.cfg.AvailableSettings.TRANSACTION_COORDINATOR_STRATEGY JavaDocs file.

The following short names are recognized: jdbc: :( default for non-JPA applications), says it uses JDBC-based transactions (org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl) jta :: says that uses JTA based transactions (org.hibernate.resource.transaction.backend.jta.internal.JtaTransactionCoordinatorImpl)

+3


source


According to http://lists.jboss.org/pipermail/hibernate-dev/2015-November/013625.html instead

<property name="transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>

      



try it

<property name="transaction.factory_class">org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorBuilderImpl</property>

      

0


source







All Articles