Please see comments below.

> -----Original Message-----
> From: Henri Dupre [mailto:[EMAIL PROTECTED]
> Sent: Thursday, September 22, 2005 12:34 PM
> To: Tapestry users
> Subject: Re: Another Stupid Hibernate Question (TP4)
> 
> On 9/22/05, Patrick Casey <[EMAIL PROTECTED]> wrote:
> >
> >         There's a third approach you should definitely consider:
> >
> >         Never detatch your persistent objects and use a long session.
> It'll
> > prevent all those nasty dirty collection, uninitialized collection, and
> lazy
> > initialization problems.
> 
> That's exactly what I am considering. Also this is the approach that
> Seam is taking (the new JBoss framework sounds to me like a
> Spring+hacks for JSF) .
> Are there any troubles by storing a Hibernate Session in a Visit?

        I dunno. I'm pretty old school so I just store it directly in the
HttpSession. I can't see why using the visit wouldn't work as well.
> 
> >
> >         The downside is that every time a page submits, it writes "live"
> > into your persistent object which will write through the next time the
> > session flushes so you have to be careful about that.
> 
> I don't see any downside here, wouldn't the same occur with a notbound
> exception in a per-session model?

        I don't think so. In a per-session model you can do a
fetch->detach->validate->merge pattern which means that your writes don't
persist if you fail validation. With the long-session model you can't do
that detach step (or you are no longer in session) so you end up writing
direct into the persistent entity.

> 
> >         Also, make sure you use temp sessions for large queries so as
> not to
> > pollute your "long" session with lots of persistent objects it doesn't
> > really need.
> 
> I guess that a downside is that the sessions get very large and suck
> memory?
> And so ideally I guess there should be 2 hibernate sessions:
> one for the "conversation" (accross several pages), and another one
> for short lived objects (per page session)?

        That'd be one approach (keeping two session). I usually just spawn
temp session though so I just use one session and then hijack its connection
when I need a new one with:

        Session temp =
HibHelper.getSessionFactory().openSession(HibHelper.getSession().connection(
));

        // fill temp session with gobs of stuff
        Temp.close();
        // temp session is now gone but parent long session lives on

        
> 
> Thanks,
> 
> Henri.
> 
> ---------------------------------------------------------------------
> 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