You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Carl-Eric Menzel <cm...@bitforce.com> on 2004/06/08 21:16:26 UTC

Re[2]: Hibernate Session to User Session

Riyad Kalla wrote:

> I believe that is what I am using now (it seems to be quite popular) but
> I don't quite understand the reasoning behind the ThreadLocal approach
> (I've actually never used 'ThreadLocal')... can you shed some light on
> this? What the mapping between Hibernate Sessions and Users (or Threads)
> becomes?

The preferred mapping is still one Hibernate Session per HTTP Request.
You would also still need a Filter that instantiates the Session when
the request comes in and closes it when it is finished. But instead of
putting it into the request as an attribute, you can put it into a
ThreadLocal. That way, all methods that need the Session can simply
use the ThreadLocal to get it and you don't have to pass around
request attributes.

Carl-Eric


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org