Hi everybody!
I'm using Hibernate in an JBOSS-Webapplication, together with Struts.
My architecture is somewhat 4-tierd with JSP, Struts, Singletons for Business-Operations and Hibernate together with Oracle.
My question now is: How and when should I call the factory.openSession() and session.close() methods. The JDBC connections are managed through JBOSS' pool. I implemented and use the HibernateUtil from the reference with the ThreadLocal session-factory.
Currently I'm opening a session at the beginning of a struts action, while passing it along to the Business-Singletons. When I read chapter 17, I somehow get the feeling that this is wrong and I should rather open() and close() in every Business-operation itself.
What should I do? And what are the different consequences on thread-safeness, connection-count and speed in the two different approaches?!
Thanks for your help!
|