cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Upayavira ...@upaya.co.uk>
Subject Re: cocoon and hibernate sessions
Date Thu, 01 Jul 2004 11:14:42 GMT
Jeremy Quinn wrote:

>
> On 1 Jul 2004, at 11:29, Upayavira wrote:
>
>> That could work, but it would be working round, rather than working  
>> with, Cocoon. You would also be buffering your output, which is best  
>> avoided.
>
>
> The solution looks far more complicated than it needs to be, also it  
> makes lazy loading pointless.
>
>> This is an issue that requires a full solution. I believe the  
>> preferred way is something like:
>>
>> cocoon.sendPageAndWait("url", bizData, function(){session.close()});
>
>
> I used the HibernateFactory component that is in the Wiki as a basis  
> for my HibernateFactory.
>
> Most of my flowscripts (for just displaying Beans) look like this:
>
> function imageRecord() {
>     var factory = cocoon.getComponent (PersistenceFactory.ROLE);
>     var session = factory.createSession ();
>     try {
>         var image = ImagePeer.load (session, new java.lang.Long  
> (cocoon.parameters["imageid"]));
>         if (image != null) {
>             cocoon.sendPage (cocoon.parameters["screen"], { image: 
> image });
>         } else {
>             cocoon.sendPage("screen/error", {message: 
> "error.no-record"});
>         }
>     } catch (e) {
>         cocoon.log.error (e);
>         cocoon.sendPage("screen/error", {message: e});
>     } finally {
>         session.close();
>         cocoon.releaseComponent (factory);
>     }
> }
>
> I use lazy-initialisation but do not have problems using JXTemplate  
> with it.
>
> If you do get lazy-initialisation errors, I think the thing to try it  
> to put this line after the cocoon.sendPage:
>
>     catch (return) {session.close ()}
>
Could you make this:
catch (return) {print "Closing session"; session.close()}

and try again. And see if it actually does close the session.

Regards, Upayavira



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message