cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Fabrizio Sitzia" <>
Subject CForms/Flowscript and Hibernate long sessions
Date Tue, 15 May 2007 09:26:25 GMT

For the past two years, I've been successfully using Cocoon and Hibernate
in various projects, based on the setup described in the Cocoon Wiki

For every incoming client request, a new Hibernate session is created, and
after rendering the view and sending the response to the client, the
servlet filter closes that Hibernate session - so far, so good!

However, for more complex scenarios which involve displaying a sequence of
forms to the user, this 'session-per-request' approach is cumbersome - as
whenever the Flowscript continuation is suspended/resumed, you have to
manually re-associate any detached objects to the new Hibernate session...

So I've taken a closer look on the long session / conversation approach
described by the Hibernate authors - although it is generally considered
an anti-pattern by most web frameworks, due to its wasteful memory
requirements and potential garbage collection issues.

But then it dawned on me that I have been using a similar anti-pattern all
along, namely Flowscript's continuations!

Correct me if I'm wrong, but all the objects which I fetch before a
continuation is suspended (and which I don't explicitly care to dispose
of!) just stay there, hogging memory ...until the user decides to resume
the continuation or until the continuation times out, right?

I am going out of my way to dispose of the (lightweight?) Hibernate
session on every client request/response cycle, while keeping all the
objects that used to be associated to the session around - plus I have to
manually re-attach them to a new Hibernate session when resuming the
continuation :-/

It therefore seems a logical step to me to extend the meaning of a
Flowscript continuation to Hibernate's understanding of a 'work unit' or
'conversation'. All there is to do is to keep one additional, lightweight
object - the Hibernate Session - in the flowscript context and to modify
the Hibernate filter and factory (outlined in the 'CocoonAndHibernate
Tutorial' Wiki) so they'll deal with long sessions, and to dispose of any
open Hibernate sessions when a continuation times out. I'm currently
testing such a modified setup in a current project.

But is my reasoning above, that a 'Flowscript continuation is indeed a
long session', correct, or did I overlook something obvious?


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message