Thank you, for response, but this is not a complete answer. My question is actually of what could be a best practice to handle a Hibernate session for a multi-page wizard. Currently my application opens a session every time it receives a request from a browser and closes it (with commit) when it sends a response. This actually means that an object is written to database every time when user moves from one page to another. This also means that an object become detached and needs reattachment on every request.
Another way to handle a hibernate session that I can think of is to store an open hibernate session in a HTTP session, and to keep it open until a user logs of or the HTTP session is expired. I am not sure that HTTP session has a hook that will allow me to do any actions upon its closing. Additional, but minor disadvantage of that scheme is that I have to commit or flush session explicitly, when a user finishes with a form, but may be this is actually an advantage.
Any other suggestions? Thank you, Lev Tannen
|