On Apr 6, 2008, at 6:48 PM, Alan Gutierrez wrote: > I'm using Guice to create a class that wraps my "business logic". > Also a class to manage a session and a transaction from Hibernate. I > implemented Guice according to this recipe. > > http://www.nabble.com/Stripes-%2B-Guice----Implemented-td9466373.html > > Instead of a static SessionFactory, I created one in a > ServletContextListener. It sets a SessionFactory into the > ServletContext. > > I did fine until I referenced a one to many relationship in my JSP > and got an error that said... > > failed to lazily initialize a collection of role: > com.thinknola.signup.Event.attendees, no session or session was closed > > So, here is the problem: > > During the event handler of my action, I close the session, before > returning the Resolution. Obviously, I need to keep the session open > after the handler, so the JSP can use it. > > What is the best place to hook Stripes for cleanup? Where should I > store the Session so that the hook can close it? I'm imaging that > there is one ActionBean per request, so I should keep a reference to > the session in the action bean, a member rather with a getter, and > get and close it where ever I create that hook.
Discovered the setAttribute method of ServletRequest. I've created a Filter. My hibernate session manager object stores the session in a request attribute. The filter runs the next filter in the chain in a try finally block. If the request contains a hibernate session attribute, the hibernate session is closed. -- Alan Gutierrez | [EMAIL PROTECTED] | http://blogometer.com/ | 504 717 1428 Think New Orleans | http://thinknola.com/ ------------------------------------------------------------------------- This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Register now and save $200. Hurry, offer ends at 11:59 p.m., Monday, April 7! Use priority code J8TLD2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone _______________________________________________ Stripes-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/stripes-users
