Yes, as you point out, there is a "CloseSession" annotation defined in Mifos which will also close the session. However, using this is not ideal, since it would currently need to be applied to every action method in order to insure that sessions are closed. The usage and design of the annotations you mention needs to be reviewed. From what I have seen thus far, I don't believe they work as it appears they were originally intended to. (Specifically, there may have been an expectation that a given hibernate session could be reused across multiple http requests, but with the current structure, this is not the case-- unless you lucky enough to have the same servlet thread service a sequence of requests) There are ways to achieve Hibernate session reuse across requests, but these techniques are not used in the current implementation. In the long run what we hope to do is move the whole transaction/session management code out of the presentation layer and into a service layer, so this usage will be refactored out at some point. At that point, we could consider using something like the declarative transaction support provided by Spring. Cheers, --Van
________________________________ From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Stephen Horgan Sent: Monday, February 18, 2008 6:26 AM To: Developer Subject: Re: [Mifos-developer] Hibernate session management Thanks for this clarification Van. I would just like to add an observation that I made when looking into session management; there is another means by which hibernate sessions are cleaned up in Mifos. Struts action classes in mifos extend org.mifos.framework.struts.action.BaseAction, which contains the method postExecute(). This method is called after every struts action, and will close the hibernate session if the calling method is annotated with the org.mifos.framework.util.helpers.CloseSession interface... example from SavingsAction below: @CloseSession @TransactionDemarcate(validateAndResetToken = true) public ActionForward create(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { // stuff ... } - Steve On 15/02/2008, Van Mittal-Henkle <[EMAIL PROTECTED]> wrote: During a recent discussion regarding connection pooling, Hibernate session management and database connection management a suggestion was made about forcing the hibernate session to close at the end of each http request. I wanted to provide a reference to what is currently being done regarding this. Curently the class org.mifos.framework.ApplicationIntitializer (which implements ServletContextListener and ServletRequestListener) defines the following method: Public void requestDestroyed(ServletRequestEvent event) { HibernateUtil.closeSession(); } The intent of this method is to force the current Hibernate session to close at the end of each request. This is not how we would like to ultimately manage sessions, but it was done as a stopgap measure to avoid sessions being left open in cases where they are not closed properly. --Van ------------------------------------------------------------------------ - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
