Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
Hibernate 3.1 beta 2
Mapping documents:
Annotations w/ JBoss 4.03RC2 + EJB3
I currently have an app that uses Hibernate 2 and the ThreadLocal web filter pattern to keep the session open so that I can lazy load collections in the web tier (jsp) as desired. This works very well. (Yes, I realize detached objects are the "proper" way to communicate between the web and ejb tier)
When testing with the new versions of Hibernate and JBoss, the connection is always closed and I get lazy execeptions in the jsps. I tried turning the auto-close off using the hibernate properties. However, from reading the 3.1 docs I believe the problem stems from this comment:
... the SessionFactory provides the getCurrentSession() method, which returns a session that is bound to the JTA transaction context. This is the easiest way to integrate Hibernate into an application! The "current" session always has auto-flush, auto-close and auto-connection-release enabled (regardless of the above property settings).
So is the thread local pattern no longer viable with 3.1? Is there no way to turn off auto-close? I can work with this constraint; however, it's really nice not having to worry about initializing collections in the ejb tier, thus gaining the benefit of lazy loading only when a jsp requires it (not to mention filtering collections for paging).
Thanks.