tapestry-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From psy...@t-online.de (John Meredith)
Subject Re: hibernate/tapestry & lazy initalization
Date Tue, 06 Jan 2004 19:32:19 GMT
Hi John,

Somehow I missed the original post (no idea where my filters have
filtered it off to) ...

Anyway, what I find works very well is the "Open Session in View"
pattern/filter: http://www.hibernate.org/43.html

A session is opened for the entire request and automatically closed.

Another thing worth looking into is possibly the Spring Framework. I've
played around with it briefly ... from memory, there's also a tutorial
available for using Tapestry + Spring + Hibernate on their Wiki.

Hope this helps.

  - John

On Tue, 2004-01-06 at 20:19, Eric Schneider wrote:
> John,
> 
> Try creating the session in prepareForRender(), see if that makes a
> difference.
> 
> Cheers,
> Eric
> 
> ----- Original Message ----- 
> From: "Jamie Orchard-Hays" <jamie@dang.com>
> To: "Tapestry users" <tapestry-user@jakarta.apache.org>;
> <studarus@jhlconsulting.com>
> Sent: Tuesday, January 06, 2004 2:11 PM
> Subject: Re: hibernate/tapestry & lazy initalization
> 
> 
> > I don't think initialize() is where you want to do this. That's where you
> > set properties to the default values you want when you are *finished* with
> > the page (usually null).
> >
> >
> > ----- Original Message ----- 
> > From: "John Studarus" <studarus@jhlconsulting.com>
> > To: <tapestry-user@jakarta.apache.org>
> > Sent: Tuesday, January 06, 2004 1:29 PM
> > Subject: hibernate/tapestry & lazy initalization
> >
> >
> > >
> > >   I've been using Tapestry with Hibernate (and Tomcat 5)
> > > for a few months now with great results.  I recently ran
> > > into a problem that I am curious if anyone else has
> > > encountered.
> > >   I've been rely upon Hibernate to populate objects
> > > for me from the database via OGNL calls in Tapestry.
> > > However, at times, Tapestry calls Hibernate objects
> > > (like the source in a foreach) without hitting any of
> > > my code.  This means I don't have the opportunity to
> > > create a Session for Hibernate to use and I end up
> > > with an exception.
> > >   I need to be able to create a session object
> > > before Tapestry makes any calls into my Hibernate
> > > objects.  Any ideas on how this could be done?  I've
> > > created the Hibernate sessions in both the Tapestry
> > > page constructor and inside the initialize call.  I
> > > get the exception when Tapestry pulls up the Hibernate
> > > object.  Or I wonder if Tapestry is doing its work
> > > in a different thread than my code and can't see
> > > my Thread specific session.
> > >   This only effects Tapestry/Hibernate when lazy initalization
> > > is turned on.  I have a feeling that most people use
> > > lazy initalization when using Tapestry and Hibernate together
> > > but the performance hit is too great for me to leave lazy
> > > initalization turned on (difference between something taking
> > > 1.5 hours or 30 seconds...).
> > >   There was a post out there about using a Filter - anyone
> > > every tried that?  Any Hibernate/Tapestry experts out there?
> > >   Thanks,
> > >
> > >         John
> > >
> > > net.sf.hibernate.LazyInitializationException: Failed to lazily
> initialize
> > a collection - no Session
> > >         at
> >
> net.sf.hibernate.collection.PersistentCollection.initialize(PersistentCollec
> > tion.java:167)
> > >         at
> >
> net.sf.hibernate.collection.PersistentCollection.read(PersistentCollection.j
> > ava:64)
> > >         at net.sf.hibernate.collection.Set.size(Set.java:114)
> > >         at
> >
> org.apache.tapestry.Tapestry$CollectionIteratorAdaptor.coerce(Tapestry.java:
> > 568)
> > >         at
> > org.apache.tapestry.Tapestry.coerceToIterator(Tapestry.java:864)
> > >         at
> > org.apache.tapestry.components.Foreach.getSourceData(Foreach.java:113)
> > >         at
> > org.apache.tapestry.components.Foreach.renderComponent(Foreach.java:126)
> > > ...  cut ...
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> > >
> > >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
-- 
John Meredith <psynix@t-online.de>


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


Mime
View raw message