If you are using JBoss there's a built-in interceptor and a Hibernate MBean that handles the opening and closing of sessions. Just an FYI as I always though implementing the ThreadLocal on your own was a hack.
On Thu, 2005-05-19 at 08:22 +0200, Schulte Marcus wrote: > I'm using the long session pattern put forward in HIA by Bauer&King. This > works very well - no LazyInitializationException nor > NonUniqueObjectExceptions when re-attaching objects. In fact, no > re-attaching at all. > The recipe is: > 1. ServletFilter to manage mapping of Http-Sessions to Hibernate-Sessions > and putting the latter in a convenient ThreadLocal > 2. An IActionListener-Wrapper to commit/rollback as desired > 3. Not forgetting to close your Session and throw away your persistent > objects at an appropriate point (typically, this is "user choses new > working-set" or somethin like that) > Only "drawback" - the pattern is not supported by any IoC-Containers out of > the box - at least by none I know of. > If anybody is interested I could post some code ... > > Marcus > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
