cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Reinhard Pötz <reinhard_po...@gmx.net>
Subject RE: Flow Database stuff ( The new FOM? )
Date Fri, 11 Jul 2003 16:45:42 GMT

From: Jeremy Quinn

> The problem arises when you wish to use a (brilliant) feature of 
> Hibernate called 'lazy-initialisation', whereby access to the DB is 
> only made when you actually ask for Bean Properties.
> 
> This is particularly useful when you have large 'graphs' of related 
> Beans, for instance child/parent relationships, whereby loading one 
> Bean may result in the whole database loading!!
> 
> If you have closed your Hibernate Session in your Flowscript, your 
> display layer can throw LazyInitialisationExceptions, because the 
> connection is no longer available.
> 
> Not closing the Session after you have sent the Response, is 
> considered 
> bad practise, so the Servlet Filter is a handy solution.

It's a pity that Hibernate is under LGPL - this would be a great example
...
Have the Hibernate people ever been asked if they would put their
great piece of software under a more Apache like licence?

As I'm curious I have a technical question:
What's the difference if I read the necessary data in the flow or some
milliseconds latter in the view layer? What do I gain?


> >> However, with the generous assistance of Ugo Cei, I am 
> successfully 
> >> using the technique highlighted in the first sample here [1] for 
> >> managing Hibernate Sessions in my FlowApp.
> >>
> >> The basic issue is that you want to avoid maintaining an open 
> >> Hibernate Session whilst the user is interacting with a 
> form (etc.).
> >> The Session
> >> should to be opened and closed during each Request (and any
> >> Transient
> >> Beans refreshed before re-use). The above technique uses a Servlet
> >> Filter to manage this, with a static method to retrieve a 
> Session in
> >> your flowscript at the beginning of each Request that needs it.
> >>
> >> [1] http://hibernate.bluemars.net/43.html
> >>
> >
> > Sounds cool and I remember that I've already heard from it 
> but haven't 
> > found the time to try it myself.
> 
> I am using it ATM on a client project and it is a dream!
> 
> > <dream-mode>
> >  I would like to use this Avalon component mentioned above and  the 
> > Flow interpreter takes care of releasing (and providing)  stateful 
> > components within my scripts. So I would have to  lookup 
> the Hibernate 
> > Session at the beginning(2) and until I  finally release(8) 
> it I don't 
> > have to take care for it.
> >
> >  1  function xxx() {
> >  2    var hibS = cocoon.getComponent( "hibernateSession" );
> >  3    var custBean = hibS.blablabla // get your beans with hibernate
> >  4    sendPageAndWait( "bla", {customer : custBean} );
> >  5    // do something (updates, reads, whatever)
> >  6    var someDifferentBean = hibS.blalbalba
> >  7    sendPageAndWait( "bla", {diff : someDifferentBean } );
> >  8    sendPageAndRelease( "thankYou", {} );
> >  9  }
> >
> >  This would be IMO a very elegant way and IIU the recent 
> discussion  
> > correctly possible from a technical point of view. Maybe Chris  can 
> > comment on this :-)
> >
> >  Thoughts?
> 
> This is a reality!
> Wake up and smell the toast ;)

;-)

> 
> I just do not use the Component Manager, because I cannot manage the 
> Hibernate Session entirely from the FlowScript layer as explained 
> above. I have a static method that gives me a fresh Session. I get s 
> Session at the beginning of  Function, or directly after a 
> sendPageAndWait().

Is it possible to have a look at the sources? I would be very
interested!

Cheers,
Reinhard




Mime
View raw message