Hi Chris,
That would be great except that by using tapestry-hibernate, I'm allowing
tapestry to create an entirely new instance of the Hibernate SessionFactory
just for itself (seems like a waste of memory). Also in order for that to
work I'd have to move all my Hibernate configuration stuff out of Spring's
XML and into its own hibernate.xml file on the classpath. It's a good
suggestion, and as a last resort I may have to go that route. I was just
fishing for an alternative way to have Tapestry request the main
SessionFactory from Spring, or have Spring configure tapestry and "push in"
the SessionFactory.


Chris Lewis-5 wrote:
> 
> I'm showing my inexperience with hibernate in web applications here, but 
> tapestry-hibernate provides a thread-safe session-per-request 
> implementation by default 
> (http://tapestry.apache.org/tapestry5/tapestry-hibernate/). Is this not 
> sufficient?
> 
> trekmbikes wrote:
>> I'm brand new to Tapestry. I have a large application that uses Spring to
>> configure the Hibernate SessionFactory. I have a request interceptor
>> defined
>> in Spring so that I can bind a Hibernate session to each request's
>> thread.
>> Closure of the session is deferred until the request returns, to prevent
>> LazyLoadingExceptions (OpenSessionInViewInterceptor)
>>
>> I need to apply the same hibernate-session-per-reqeust feature to the new
>> Tapestry code I'm writing, which will only be a small part of a much
>> bigger
>> system.
>>
>> My ideas are:
>> a - Call Tapestry's filter methods from a custom Spring controller, then
>> assign interceptors to the controller. This isn't working because the
>> controller needs to be mapped to some URL pattern in web.xml (either like
>> "/tap/*" or "*.tap"). It seems like Tapestry's filter doesn't like to be
>> mapped to anything other than "/*". I need to keep the tapestry requests
>> separate from all the other servlet mappings for now. I successfully
>> mapped
>> the controller to "/tap/*", which activated the interceptor, but then
>> tapestry choked handling the real request.
>> b - Change the OpenSessionInViewInterceptor to an
>> OpenSessionInViewFilter.
>> This would work if I declared the filter before the Tapestry filter in
>> web.xml. But, some of my Spring servlets don't need this database
>> connection, so I would be opening and closing the session unnecessarily.
>> c - Use the Tapestry-Hibernate module and have Tapestry configure
>> Hibernate
>> independently from Spring. This is annoying because I'll have to move all
>> my
>> Hibernate configuration out of the spring XML it's in, and into a
>> separate
>> file. Plus, I'll have two complete SessionFactory instances when I really
>> only needed one.
>> d - I tried looking into the dispatcher classes but there's no
>> "afterReturn()" method, only dispatch(). So I have no way to close the
>> session/connection after the request returns.
>>
>> Suggestions would be much appreciated!
>>   
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/T5---Spring---Hibernate-Lazy-Loading-tf4685218.html#a13393791
Sent from the Tapestry - User mailing list archive at Nabble.com.


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

Reply via email to