3
votes

I want to Integrate Spring and Hibernate and use JTA for managing the transactions. I would also like to delegate transaction handling to the App server, which in my case is JBoss. I have a query regarding the configuration of the "transactionManager" bean in Spring:

1) Can we use HibernateTransactionManager and set the the properties hibernate.transaction.factory_class and hibernate.transaction.manager_lookup_class in hibernate.properties file? If not, why?

2) Or, should we use JTATransactionManager?

In option (2), do we still need to set the properties("hibernate.transaction.factory_class", "hibernate.transaction.manager_lookup_class") in hibernate.properties?

Thanks.

1
what application server are you running on? regarding JTA, do you want to delegate transaction handling to your appserver? on 1), what factory and lookup class do you want to specify?abalogh
JBoss. Yes, I would like to delegate transaction handling to the App server. My question is that - Can we achieve JTATransaction management by using HibernateTransactionManager and by setting the appropriate factory and lookup classes in hibernate.properties?saravana_pc

1 Answers

4
votes

If you want to delegate to the appserver, you have to use JTATransactionManager to my knowledge, HibernateTransactionManager is not a JTA transaction manager.

PlatformTransactionManager implementation for a single Hibernate SessionFactory. Binds a Hibernate Session from the specified factory to the thread, potentially allowing for one thread-bound Session per factory. SessionFactoryUtils and HibernateTemplate are aware of thread-bound Sessions and participate in such transactions automatically. Using either of those or going through SessionFactory.getCurrentSession() is required for Hibernate access code that needs to support this transaction handling mechanism.