What is the difference between org.hibernate.context.JTASessionContext and org.hibernate.context.ThreadLocalSessionContex?
With ThreadLocalSessionContext, the current session (sessionFactory.getCurrentSession()) is created and stored in a ThreadLocal. This works in any environment, because ThreadLocal is JavaSE.
JTASessionContext binds the current session to a JTA transaction. The JTA transaction provides a hook for cleanup, unlike the thread local. This is available in environments that have JTA, such as an application server.
This all is explained in the javadocs of the two classes. here and here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With