The best references here are Open Session in View pattern http://hibernate.org/43.html and, if you use Hibernate 3.1, generic DAO pattern http://hibernate.org/328.html and the latest Caveat Emptor (alpha 5) http://caveatemptor.hibernate.org/ constantly updated for Hibernate in Action 2nd edition covering Hibernate 3.0 and 3.1
It is up to you to choose between session-per-request or session-per-conversation. Using generic DAO pattern you minimize your DAO layer as much as possible. Sergiy ================== Multiplex Systems LLC http://www.mpxsys.com -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 11, 2006 9:20 AM To: Tapestry users Subject: Re: Best Practice (Hibernate, Spring, Tapestry) I just went thru Hibernate In Action (edition 1), chapter 8.2 (Implementing Application Transactions). This chapter talks about the two options we talked about, and a third option: Long Session. It seems that "Hibernate in Action" recommends Long session on a web application over other two. The next preferred option is "Detached Persistent Object Strategy" (same as option 1 in my original email). Will this new information change your opinions on these options? Thanks .... Shovon ----- Original Message ---- From: Patrick Casey <[EMAIL PROTECTED]> To: Tapestry users <[email protected]> Sent: Tuesday, January 10, 2006 6:40:29 PM Subject: RE: Best Practice (Hibernate, Spring, Tapestry) I'd generally be inclined to go with Option #2. Loading an object in session A, then reattaching it to session B (with, for example, Session.lock()) is a bit of a code smell with hibernate, especially if there's any chance the object might have been changed by another thread between initial load and reattachment. Likewise there's the issue that if you're storing the whole thing in the HTTPSession that burns memory *and* requires that all your POJO's implement serializable. All in all, I'd go with key and reload; it's what I do about 95% of the time except for a few special cases where I need to keep the object and session between screen renders, in which case I just store store the Hibernate session in the HTTPSession (which I wouldn't recommend as a general case solution). --- Pat [EMAIL PROTECTED] --------------------------------------------------------------------- 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]
