You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Jeff Gager <Je...@bapensions.com> on 2004/02/18 13:05:48 UTC

Managing Hibernate Sessions

I am trying to decide the best way to manage Hibernate Sessions in a small
Tapestry web-app for our Intranet.

My initial approach was to create a new session in setupForRequest() and
close it in cleanupAfterRequest().

This worked fine at first but then I tried to implement an audit trail, and
found that the previous values were not available. This is because the
previous values were were in the Session created for the request cycle that
displayed my data input page, which has been closed and replaced by a new
session in the request cycle that actions the update.

So I need my Hibernate Sessions to persist beyond the request cycle, but I
don't want it in the visit so where should it go?

I found references to something called HibernateMonitor but I can't find the
source for this anywhere.

I also found indications that some people have created a session for each
page, opening it in initialize() and closing it in detach(). 

I would really appreciate some advice before I invest too much time in going
down a blind alley.

Thanks in advance

- Jeff




**********************************************************************
This message is intended only for the use of the intended recipients to whom
it is addressed.
It may contain information which is privileged and confidential within the
meaning of applicable law.
If you are not the intended recipient, please contact the sender as soon as
possible.
The views expressed in this communication may not necessarily be the views
held by British Airways Pensions.
**********************************************************************

Re: Managing Hibernate Sessions

Posted by Paul Ferraro <pm...@columbia.edu>.
Check out the ThreadLocal session pattern...
http://www.hibernate.org/42.html

Paul Ferraro

Jeff Gager wrote:

>I am trying to decide the best way to manage Hibernate Sessions in a small
>Tapestry web-app for our Intranet.
>
>My initial approach was to create a new session in setupForRequest() and
>close it in cleanupAfterRequest().
>
>This worked fine at first but then I tried to implement an audit trail, and
>found that the previous values were not available. This is because the
>previous values were were in the Session created for the request cycle that
>displayed my data input page, which has been closed and replaced by a new
>session in the request cycle that actions the update.
>
>So I need my Hibernate Sessions to persist beyond the request cycle, but I
>don't want it in the visit so where should it go?
>
>I found references to something called HibernateMonitor but I can't find the
>source for this anywhere.
>
>I also found indications that some people have created a session for each
>page, opening it in initialize() and closing it in detach(). 
>
>I would really appreciate some advice before I invest too much time in going
>down a blind alley.
>
>Thanks in advance
>
>- Jeff
>
>
>
>
>**********************************************************************
>This message is intended only for the use of the intended recipients to whom
>it is addressed.
>It may contain information which is privileged and confidential within the
>meaning of applicable law.
>If you are not the intended recipient, please contact the sender as soon as
>possible.
>The views expressed in this communication may not necessarily be the views
>held by British Airways Pensions.
>**********************************************************************
>
>  
>


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