Hello,
There are FAQs and Best Practices which suggest storing
Quote:
the session in a thread local variable. I was wondering wh
y this is done, and how this works in an environment with distributed transactions.
It seems to me as if it would be easier and cleaner to perform "Each interaction with the persistent store in a new Session" (
http://www.hibernate.org/hib_docs/refer ... tions.html), i.e. open & close for each access.
the design I'm looking at is Session Facade -> DAO -> Hibernate
From the examples I've seen, there was very clear transaction demarcation, e.g. from a Session Facade. However, with distributed transactions, the Transaction can be demarcated completely outside the Session Facade (e.g. from a remote app server which is calling into the Session Facade). In this case, there is no way of knowing when the transaction ends, and no way of closing the session.
Thanks,
Vj