What I do is use a Hibernate Servlet Filter that closes the Hibernate
session 
at the end of the request.  This is used in conjunction with the
HibernateUtils
class that stores the Hibernate session in ThreadLocal storage.


An example of this technique is on the Hibernate site
(http://www.hibernate.org/43.html)




-----Original Message-----
From: news [mailto:[EMAIL PROTECTED] On Behalf Of Konrad Billewicz
Sent: Tuesday, August 09, 2005 10:11 AM
To: user@struts.apache.org
Subject: Struts and Hibernate lazy

Hello,

I am using Hibernate in my Struts project. A have a problem with
Hibernate lazy 
option. When I am setting it to true, I get an error in my JSPs:

org.apache.jasper.JasperException: could not initialize proxy - the
owning 
Session was closed

Of course I know why this error occurs. I am closing the session at the
end of 
each action - before JSPs processing. My question is how clever solve
this 
problem? lazy="false" is not acceptable because I have a table with so
many 
joins that database is going down.

My only idea is to include a bean and run sessionClose() method at the
end of 
each JSP... but it is a very dirty method. :-( As far as I know, there
is no 
method to run any code "at the end" of Struts execution.

If you have any ideas or solutions I would be very gratefull.

Best regards,
Konrad Billewicz



---------------------------------------------------------------------
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]

Reply via email to