Hello Stephan, Wednesday, June 30, 2004, 12:12:10 PM, you wrote:
> Jakob Schwendner wrote: >>Hi, >> >>I am using cocoon 2.1.5 and hibernate. I have got a component wrapping the >>SessionFactory and as far as I can tell everything seems to work pretty well. The >>issue is that I am using a >>session-per-user-session anti-pattern as defined by the hibernate documentation >>http://www.hibernate.org/168.html. I would like to move to a session-per-request >>pattern. I figured it would be easy >>to keep a session per thread using a ThreadLocal. The only problem is that I don't >>know where I could close the session again. >>Has anyone done this before? If not, where would be good points to create and close >>the hibernate session. Maybe in the flow using a threadlocal and close it whenever a >>page view is called? The >>problem with that is that the session would need to stay open until after the view >>call as there might be lazy objects that get displayed. >>Any help appreciated, >> >> > Hi Jakob, > I think this problem was discussed here before several times. Not tested > and just an idea: Why not store the Hibernate-Session-Object into the > Request-Scope and writting an action which extracts the > Hibernate-Session and closes them after generating the view. A pipeline > fragment could be looked like the following: > <map:match pattern="foo.jxt"> > <map:generate type="jxt" src="foo.jxt"/> > <map:act type="closeHibernateSession"/> > <map:serialize type="html"/> > </map:match> > Regards Another possibility is using Filter to open/close hibernate session as http://www.hibernate.org/43.html. This way was also discussed previously in the list. I plan to try to implement this method in my project. -- Best regards, Peter Velychko [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
