I'm trying to get an understanding of how the transaction context would work in a multi-threaded environment. I want to understand how to use it as well as how it's internally implemented (high level) if possible.
So say I have two parallel threads and/or I want the transactional boundaries to span two separate requests (different threads).
I don't know if SessionFactory stores the session context as a ThreadLocal variable, but my understanding is that the same session will be returned within the same thread, being that the transactions has not been started and committed.
So basically the question is whether it's the Transaction context and/or Session, I'd like to get access to same session context across threads, basically to ensure it has the same jdbc connection object, as well as demarcate the transaction across threads. Is this something that hibernate provides and/or what would be the best way of implementing it.
Thanks.
Ilya Sterin
|