Ok, thanks. This is what I did.
public class RequestCycleImpl extends WebRequestCycle {
private Session hibernateSession;
public RequestCycleImpl(Application application, Request request,
Response response) {
super(application, (WebRequest) request, response);
}
@Override
protected void onBeginRequest() {
this.hibernateSession =
HibernateUtil.getSessionFactory().openSession();
}
@Override
protected void onEndRequest() {
if (this.hibernateSession != null) {
this.hibernateSession.close();
}
}
public Session getHibernateSession() {
return hibernateSession;
}
}
Eelco Hillenius wrote:
On 10/4/07, Stanczak Group <[EMAIL PROTECTED]> wrote:
How can I access the request cycle so I can open and close a Hibernate
session on each request?
In your application class:
@Override
public RequestCycle newRequestCycle(Request request, Response response)
{
return new WebRequestCycle(this, (WebRequest)request, response)
{
@Override
protected void onBeginRequest()
{
// open session
}
@Override
protected void onEndRequest()
{
// close session
}
};
}
If you use Spring for instance, you could just configure the hibernate
session filter that comes with it instead.
Eelco
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
Justin Stanczak
Stanczak Group
812-735-3600
"All that is necessary for the triumph of evil is that good men do nothing."
Edmund Burke
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]