I've successfully deployed several Tapestry/Hibernate applications using Spring as the glue. Personally, I find Hibernate development is made easier with Spring, even in small projects. I can't imagine using Hibernate without using Spring. The two work hand-in-glove. Spring's declarative transaction handling alone is worth the price of admission.
As for the OpenSessionInView filter provided with Spring, it works great with Tapestry applications. Most folks run into problems with Tapestry and Hibernate because they're not careful with lazy properties and detached objects. With Tapestry's wealth of options for dealing with object data in a page it's very easy to get your hibernate objects detached from a session. That can cause the two exceptions everybody encounters (and unfairly blames on the Hibernate/Tapestry combo): The infamous net.sf.hibernate.LazyInitializationException And the insidious net.sf.hibernate.NonUniqueObjectException These two problems are easily solved by using the OpenSessionInView pattern and by carefully managing when and where objects are serialized into either the Session (as persistent properties) or the Page (as hidden fields, parameters, etc. - use "View Source" to make sure there aren't unexpected hibernate serializations into your page.) -----Original Message----- From: Cory Watson [mailto:[EMAIL PROTECTED] Sent: Saturday, September 17, 2005 9:20 PM To: Tapestry users Subject: Another Stupid Hibernate Question (TP4) I can't find a definitive answer for how to utilize Hibernate properly in Tapestry. I used to use a 'Session In View' by way of a HibernateHelper class with that held the session in a ThreadLocal, then utilized my Engine's cleanupAfterRequest(). This suddenly no longer works right in TP4. My cleanupAfterRequest() never gets called. I see custom services, hivetranse, spring, and servlet filters. I realize that all of these probably have their place, but I don't understand which one is good for me. I'm a bit leery of using Spring for something this simple, and the hivemind ways scare me because i only see whispers of it and no examples that help me understand how to do it. So help a guy out. What's the best way to accomplish the proper session.close() and session.flush() at the end of a request? That's all I'm after. For now I'll use a servlet filter. Cory Watson http://www.onemogin.com --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
