You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Eric Everman <ev...@precedadesign.com> on 2003/03/02 23:54:10 UTC

Hibernate 1.2 Thread Local Sessions (off topic)

Per Norrman-

As related to Tapestry, am I right in assuming that the same hooks are 
needed to ensure that sessions are closed properly?

I remember skimming some Hibernate email about thread local sessions, but I 
wasn't aware that they were now part of the API.  I looked at the Hibernate 
wiki and docs, but didn't see anything.  Could you point me to some info on 
this?

Also, what are the advantages to this approach over using 
Hibernate.configure()?


Thanks,

Eric Everman


At 3/1/2003, you wrote:
>Hi,
>
>As a side note on this topic, I would just like
>to contribute the solution I've come up with.
>
>It is Hibernate (1.2) specific, and uses the utility Persistence class
>and the TxCommand interface. You call Persistence.init(..) once to set up
>the Hibernate datastore etc. Then you just wrap all your transactional
>code in a TxCommand.perform method and call Persistence.doTransaction(..).
>Hibernate sessions are created on demand and stored in a thread local
>object.
>
>Some interceptor or bracketing mechanism (ServletFilter, Monitor, Action)
>closes the session by calling Persistence.close() when the transaction
>is done. Commit or rollback is automatically taken care of depending on the
>outcome of the doTransaction method(s).
>
>A ServletFilter example as well as an example of using the stuff is also
>attached.
>
>/regards
>         Per Norrman
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org