Hibernate version:2.1.8
I want to talk about the session used with Tomcat.
There are many articles that are examples about using ThreadLocal in Servlet or Filter. And all the articles recommands us CLOSE session before leaving the current thread.
I followed the recommandation and examples, but do they just work in simple situation? If an entity has one-to-many items. In first HTTP request, this entity was loaded. But when I want to use its items in the second HTTP request. I will get "session was closed" exception. This exception was occured because this entity was associated with the previous session which has been closed in first HTTP request.
I followed the "HibernateUtil" example
http://www.hibernate.org/hib_docs/reference/en/html/quickstart.htmland session was closed before leaving my Filter. It works fine except the problem I mentioned above.
How do I solve this problem? Any suggestion?
Thanks,
Matt