Managed vs jta session scope in hibernate

I was looking through the book Nuclear Persistence with Hibernation and was stuck on page # 494. We continue the conversation, establishing hibernate.current_session_context_class to managed;whether this means that I cannot use ' jta (or javax.jta.UserTransaction)' inside my methods?

These assumptions get stronger when I look at the interceptor code on page # 494. In the interceptor, we call " session.beginTransaction", which means that we use the Hibernate transaction API to manage the transaction.

Does this mean that my objects cannot use UserTransaction.begin () / commit () to manage the transaction?

I say this because somewhere in this book I even read that when you use UserTransaction to manage transaction borders, you should not use the Hibernate transaction API?

You need help here.

+3
source share
1 answer

First, IMHO, the book you mentioned is great, but a little outdated. But I can safely assume that your question is based on what is called "Contextual Sleep Sessions." This is basically the context in which you want Hibernate to manage the transaction scope. This context controls the mechanics of the sessionFactory.getCurrentSession () method.

Three possible configurations for hibernate.current_session_context_class:

  • "jta" context = already existing transaction jta li>
  • "thread" context = ( ThreadLocal)
  • "managed" context = custom

:

  • "jta" "thread"
  • "" , spring
  • "jta" Java EE

:

http://community.jboss.org/wiki/SessionsAndTransactions

http://community.jboss.org/wiki/OpenSessionInView

, - "" . . :

" Java " # 494. , hibernate.current_session_context_class ; "jta ( javax.jta.UserTransaction)" ?

- , .

, UserTransaction.begin()/commit() ?

- , "jta" "thread" .

+4

All Articles