Christian Bauer wrote:

While I'm at it: Another rework, or at least a discussion about it, for
2.0 would be the automatic reconnect of Sessions. You once mentioned
that in a forum post, but didn't like it.


My two cents:

If you've learned the basic concepts of O/R mapping, it's easy to produce a real, working and maintainable two-tiered application with Hibernate.

Just use lazy collections and disconnect/reconnect the Session which is
stored in the HttpSession. At least for web applications, that is. If
you don't require the lazy loaded collection in a Servlet call or JSP,
you could even just close it and reopen it at the next call.

In a three-tiered architecture, the recommended approach we currently
propagate is to just open new Sessions and close them with each
transaction. Some people realized that their JSP pages at the top of the
system can also start transactions (by calling transactional methods on
the Business Facade) and therefore open/close Hibernate Sessions in the
Persistence Layer somewhere further down in the system.

They immediately face the problem of lazy loaded collections: Loading an
object at the "top" of the JSP page (results in open/retrieval/close or
reconnect/retrieval/disconnect of a Hibernate Session) and using the accessors further "down" in the JSP will fail. So they have to either


a) Delay the closing of the Session until the JSP is rendered
b) Delay the disconnection of the Session until the JSP is rendered

Of course this can't happen in the JSP itself, the ViewController (the
handler of Views) should somehow send a notify which will magically
close/disconnect the Hibernate Session after the read and the whole rendering is finished.



Have you considered using a filter to close the Session after everything is rendered?



-Mark






-------------------------------------------------------
This SF.NET email is sponsored by:  The Best Geek Holiday Gifts!
Time is running out!  Thinkgeek.com has the coolest gifts for
your favorite geek.   Let your fingers do the typing.   Visit Now.
T H I N K G E E K . C O M        http://www.thinkgeek.com/sf/
_______________________________________________
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel



Reply via email to