I've been hearing this from the Spring set. I'm waiting for a good book to
come out on it.

The only reason I asked is an application I was maintaining (it had been
written using method #2) had some Session/Transaction handling bugs exposed
when migrated it to Hibernate 3. So I decided to refactor it to the way I
usually do handle the issue (not as a fix per se, just so I could understand
what was happening more easily -- thread debugging...ewww) and, lo, it
solved the problem.

I'm probably going to deploy it like this since its usage makes it no way
likely to encounter a scaling issue, but it got me wondering about where the
bathwater began and where the baby ended.

-----Original Message-----
From: Brandon Mercer [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, March 01, 2005 4:48 PM
To: Struts Users Mailing List
Subject: Re: Hibernate and Struts Usage Pattern question/survey

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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to