I didn't mention Spring because I didn't want to complicate things yet,
but yes Spring will be used and already is (just not from within
Cocoon). I'll check that link you sent. Thanks.

Brian

On Mon, 2005-01-17 at 16:25, Mark Lundquist wrote:
> On Jan 17, 2005, at 11:11 AM, Brian Burridge wrote:
> 
> >
> > Where do I put the code to get the Hibernate objects? Right now, with
> > the GUI framework they have, its done in a Struts action, which then
> > forwards to a JSP page and uses struts tags to display the contents of
> > the objects.
> 
> If you implement your model in Java, then you get to use the Spring 
> framework w/ Hibernate.  Follow the instructions at 
> http://new.cocoondev.org/main/117/43.html and study that example!  Many 
> consider using Spring in this way to be the best practice for the 
> Cocoon+Hibernate combo.
> 
> If you don't do it that way, then you pretty much have to invoke the 
> Hibernate code from the flowscript.  You're going to open a Session and 
> start a Transaction, do some Hibernate stuff, etc.,  call sendPage(), 
> then end the Transaction and close Session.
> 
> The method to load the persistent object doesn't have to be called 
> directly in flow; you can call it from down in your model layer, but 
> then you have to pass the session down, too -- or, better: use the 
> Thread Local Session pattern (http://www.hibernate.org/42.html) (that's 
> what I would do if I weren't going to use the Spring+Hibernate stuff).
> 
> But the transaction and session have to enclose everything.  Don't make 
> the mistake of trying to bury all the hibernate stuff down in the model 
> layer (without using Spring, that is :-)... otherwise you get into 
> trouble with lazy initialization, e.g.
> 
> 1) flow calls method in model layer;
> 2) model opens session, does Hibernate stuff, closes session, returns 
> an object
> 3) flow calls sendPage();
> 4) Splaaat!  Hibernate says, "session closed or no session"
> 
> This kind of misdesign can result in kludgy workarounds.
> 
> GL, :-)
> -ml-
> 
> 
> ---------------------------------------------------------------------
> 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