struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brandon Mercer <bran...@eutonian.com>
Subject Re: Hibernate and Struts Usage Pattern question/survey
Date Tue, 01 Mar 2005 21:48:09 GMT
Joe Hertz wrote:

>Curious as to which concept Struts/Hibernate implementers like more for
>implementation:
>
>#1- Ted Husted's example of Struts and Hibernate. Stick the Hibernate
>Session object into the httpServletRequest. Every action has a fresh
>Hibernate Session raring to go if it needs it. Then again it has it even if
>it doesn't but the Hibernate folks swear that this is basically no work for
>the application. As if the guts of the Session object don't really exist
>until it's first method call.
>
>#2- Hibernate's Struts plugin concept: Getting Hibernate Sessions explicitly
>in action methods, but stashing them in a ThreadLocal to not get any you
>don't need. If you try to get it again in the same thread, you get the one
>you already had.
>
>I guess the implies solution here is "Rely on the thread destroy() method to
>kill the Session when it aint needed no more
>
>#3- something else
>
>Since Hibernate also suggests an approach similar to #1 via a Servlet filter
>anyway, I opt to do it via a Request Processor subclass.  
>
>I'm curious how other people go about it. Anyone ever encounter a reason
>they had to switch?
>  
>
Joe, I currently use struts+spring+hibernate.  The addition of spring 
helps quite a bit and gives you a very clean layout.  If done correctly 
you can switch persistance layers without any trouble.  Check out 
http://raibledesigns.com/wiki/Wiki.jsp?page=AppFuse.  It's a nifty 
toolkit that shows you how to do this very easily. 
Brandon

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message