You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Nicolas Bielza <ni...@alligacom.com> on 2004/06/08 16:48:45 UTC

Flow + Hibernate and lazy initialization

Hi,

I ran into a small problem when using hibernate inside a flowscript and
a velocity template to generate the XML from the "hibernated" objects.
Here's what I'm doing:

1. Get a hibernate session and retrieve some objects from the DB.
2. Pass these objects to a velocity generator to create some XML (I'm
calling cocoon.sendPage()).
3. Close the hibernate session.

Now, when I serialize the velocity output to XML, there's no problem; if
I add a XSL transform step and serialize to HTML, I get lazy
initialization exceptions. 

So it seems that sendPage doesn't always wait for the page to be
generated.

I fixed this issue by specifying the FetchMode to hibernate (so there's
no lazy behaviour anymore), but I'd like to know if there's a preferred
way of dealing with such problems: when can I safely close the hibernate
session ? (I think it would be nice to keep the Collection
initialization lazy)

I looked at (and stole from) the
http://wiki.cocoondev.org/Wiki.jsp?page=XMLFormJXFormHibernateAndFlowscr
ipt page, but I don't see when the session is closed (when is
UserRegistry.release() called ?).

Thanks for any idea or code sample,

Nicolas.


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


Re: Flow + Hibernate and lazy initialization

Posted by Leszek Gawron <lg...@mobilebox.pl>.
Ugo Cei wrote:

> Il giorno 08/giu/04, alle 22:34, Nicolas Bielza ha scritto:
> 
>> Thanks,
>>
>> Unfortunately, this won't work for me as I'm not running cocoon in a
>> servlet container.
> 
> 
> Then you could explicitly tell hibernate to fetch the child collections, 
> possibly using the size() method:
> 
> Parent parent = session.get(Parent.class, id);
> parent.getChildren().size();
Yes, but then you loose all the "pull" possibilities of template and 
hibernate lazy collections. If you have to initialize all entities in 
the controller you bond it to view much harder as any view change has to 
  be "discussed" with the controller.
	LG

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


Re: Flow + Hibernate and lazy initialization

Posted by Ugo Cei <ug...@apache.org>.
Il giorno 08/giu/04, alle 22:34, Nicolas Bielza ha scritto:

> Thanks,
>
> Unfortunately, this won't work for me as I'm not running cocoon in a
> servlet container.

Then you could explicitly tell hibernate to fetch the child 
collections, possibly using the size() method:

Parent parent = session.get(Parent.class, id);
parent.getChildren().size();

	Ugo


-- 
Ugo Cei - http://beblogging.com/


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


RE: Flow + Hibernate and lazy initialization

Posted by Nicolas Bielza <ni...@alligacom.com>.
Thanks,

Unfortunately, this won't work for me as I'm not running cocoon in a
servlet container.

Nicolas.

-----Original Message-----
From: Ugo Cei [mailto:u.cei@cbim.it] 
Sent: 8 juin, 2004 11:22
To: users@cocoon.apache.org
Subject: Re: Flow + Hibernate and lazy initialization


Nicolas Bielza wrote:
> Hi,
> Now, when I serialize the velocity output to XML, there's no problem; 
> if I add a XSL transform step and serialize to HTML, I get lazy 
> initialization exceptions.
<snip/>
> Thanks for any idea or code sample,

You might try the "Open session in view" pattern:

http://hibernate.bluemars.net/43.html

	Ugo


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


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


Re: Flow + Hibernate and lazy initialization

Posted by Ugo Cei <u....@cbim.it>.
Nicolas Bielza wrote:
> Hi,
> Now, when I serialize the velocity output to XML, there's no problem; if
> I add a XSL transform step and serialize to HTML, I get lazy
> initialization exceptions. 
<snip/>
> Thanks for any idea or code sample,

You might try the "Open session in view" pattern:

http://hibernate.bluemars.net/43.html

	Ugo


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


Re: Flow + Hibernate and lazy initialization

Posted by Luca Morandini <lu...@tin.it>.
Nicolas Bielza wrote:

> I don't think it's a bug. sendPage() doesn't wait for the pipeline to
> complete.
> If I close my Hibernate connection right after the call to sendPage(),
> the lazy initialization fails (in the velocity generator step).
> I need to know when the pipeline processing is complete so I can safely
> close the session.

If one assumes sendPage to be the last statememt in a flowscript 
function, then there is no reason to wait for the pipeline to be 
processed... but if this is not true, as in your case, I think the 
"synchronize" option (to wait the end of pipeline before proceeding to 
the next javascript statement) makes sense: I presume this has to be 
raised on cocoon-dev (a thorough search in the mail archives would be 
appreciated before raising the issue on that list, of course).

Regards,

---------------------------
      Luca Morandini
    lmorandini@ieee.org
http://www.lucamorandini.it
---------------------------


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


Re: Simple question about validation

Posted by Leszek Gawron <lg...@mobilebox.pl>.
Bartosz Zgodzinski wrote:
> Hello
> Simple problem. I need to write a regular expresion. Only one word is
> prohibited: "idiota". How to write a negation in regular expresion?
> <fd:regexp pattern="idota"/> <-- this means only "idiota". Pleaste make a
> negation
really not a cocoon question
http://jakarta.apache.org/regexp/apidocs/org/apache/regexp/RE.html

-- 
Leszek Gawron                                      lgawron@mobilebox.pl

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


Simple question about validation

Posted by Bartosz Zgodzinski <ba...@poczta.onet.pl>.
Hello
Simple problem. I need to write a regular expresion. Only one word is
prohibited: "idiota". How to write a negation in regular expresion?
<fd:regexp pattern="idota"/> <-- this means only "idiota". Pleaste make a
negation


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


Re: Flow + Hibernate and lazy initialization

Posted by Leszek Gawron <lg...@mobilebox.pl>.
Luca Morandini wrote:

> Leszek Gawron wrote:
> 
>> Leszek Gawron wrote:
>>
>>>> Well, I cannot see why the releasing cannot be done in the 
>>>> Javascript statement following the sendPage... assuming the 
>>>> behaviour you observed was not just a bug in the Flowscript 
>>>> component, of course.
>>>
>>>
>>>
>>> If this is as you say you should raise this problem at cocoon-dev. I 
>>> also wanted to loose Open Session In View pattern in favor of some 
>>> hibernate avalon component, but that looks impossible now.
>>
>>
>> See this[1], and this[2] and this[3] and this[4]
>>
>> [1] http://marc.theaimsgroup.com/?t=108681937800001&r=1&w=2&n=2
>> [2] http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=105825181219265&w=2
>> [3] http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=105825410721036&w=2
>> [4] http://wiki.cocoondev.org/Wiki.jsp?page=RhinoWithContinuations
>>     LG
> 
> 
> Thanks for the interesting pointers... but I still cannot see a logical 
> reason for Rhino to execute the next Javascript statement before 
> completing the pipeline referenced in "sendPage".

The only thing I can think of is early resource releasing.

-- 
Leszek Gawron                                      lgawron@mobilebox.pl


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


Re: Flow + Hibernate and lazy initialization

Posted by Luca Morandini <lu...@tin.it>.
Leszek Gawron wrote:

> Leszek Gawron wrote:
> 
>>> Well, I cannot see why the releasing cannot be done in the Javascript 
>>> statement following the sendPage... assuming the behaviour you 
>>> observed was not just a bug in the Flowscript component, of course.
>>
>>
>> If this is as you say you should raise this problem at cocoon-dev. I 
>> also wanted to loose Open Session In View pattern in favor of some 
>> hibernate avalon component, but that looks impossible now.
> 
> See this[1], and this[2] and this[3] and this[4]
> 
> [1] http://marc.theaimsgroup.com/?t=108681937800001&r=1&w=2&n=2
> [2] http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=105825181219265&w=2
> [3] http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=105825410721036&w=2
> [4] http://wiki.cocoondev.org/Wiki.jsp?page=RhinoWithContinuations
>     LG

Thanks for the interesting pointers... but I still cannot see a logical 
reason for Rhino to execute the next Javascript statement before 
completing the pipeline referenced in "sendPage".

Regards,

---------------------------
      Luca Morandini
    lmorandini@ieee.org
http://www.lucamorandini.it
---------------------------


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


Re: Flow + Hibernate and lazy initialization

Posted by Upayavira <uv...@upaya.co.uk>.
Nicolas Bielza wrote:

>No, sendPageAndWait() does this. I think maybe catch(return) and the
>postpipeline function are the same thing. Anyway I tested both and they
>only work when using sendPageAndWait(), that is, when a continuation
>object is created. (This is consistent with the doc).
>  
>
Dunno whether this will work, but it is at least worth a try:

1) Edit 
$COCOON/src/java/org/apache/cocoon/components/flow/javascript/fom/fom_system.js

Just under the definition of FOM_Cocoon.prototype.sendPageAndWait, place:

FOM_Cocoon.prototype.sendPage = function(uri, bizData, fun) {
    this.sendPage(uri, bizData);
    if (fun) {
        if (!(fun instanceof Function)) {
            throw "Expected a function instead of: " + fun;
        }
        fun();
    }
}

2) Rebuild your Cocoon.
3) Try cocoon.sendPage("url", bizData, function() 
{hibernateSession.close());

I personally don't see why this shouldn't be there, and if this works, 
we can propose it as a patch.

Regards, Upayavira

>-----Original Message-----
>From: Upayavira [mailto:uv@upaya.co.uk] 
>Sent: 10 juin, 2004 13:19
>To: users@cocoon.apache.org
>Subject: Re: Flow + Hibernate and lazy initialization
>
>
>Nicolas Bielza wrote:
>
>  
>
>>I tried to use the catch(return) trick but it doesn't seem to work. 
>>(I'm using cocoon 2.1.4)
>> 
>>
>>    
>>
>Never used it, but - doesn't the cocoon.sendPage("url", {"foo":foo}, 
>function(){hibernateSession.close();});
>syntax do this?
>
>Upayavira
>
>  
>
>>I added some log messages in the flowscript and it seems that the
>>catch(return) is not executed when I call sendPage() (the script 
>>debugger also exposed this, and after a while, I started to see some 
>>warnings about unclosed sessions...).
>>
>>I tried with sendPageAndWait() and this time the catch(return) got 
>>executed, but it was called before the pipeline completed: I still had 
>>lazy initialization exceptions during pipeline processing.
>>
>>I also tried to close the session in the postpipeline code (when using
>>sendPageAndWait()) and again, the session was closed before pipeline 
>>completed.
>>
>>Here's an example flowscript (I'm not closing the session here, just
>>logging) :
>>
>>try {
>>
>> // ...
>>
>> var list = query.list();
>> cocoon.log.error("I'm about to call cocoon.sendPageAndWait()");
>> cocoon.sendPageAndWait("report.vm", {"list" : new HashSet(list)},
>>function() { cocoon.log.error("I'm in postpipeline code"); }, 0);
>> catch(return) {
>>   cocoon.log.error("I'm inside catch(return)");
>> }
>>}
>>finally {
>> cocoon.log.error("I'm inside finally block");
>> //clean up
>> cocoon.releaseComponent(hibernateFactory);
>>}
>>
>>
>>Now, here's the console output:
>>
>>Hibernate: select introspecd0_.id as id, introspecd0_.envelop as 
>>envelop, introspecd0_.reference as reference, 
>>introspecd0_.tradingPartner as tradingP4_, introspecd0_.docType as 
>>docType from Introspec_Document introspecd0_ inner join 
>>Introspec_History statushist1_ on introspecd0_.id=statushist1_.docId
>>Hibernate: select introspecd0_.id as id0_, introspecd0_.name as name0_ 
>>    
>>
>>from Introspec_DocType introspecd0_ where introspecd0_.id=?
>  
>
>>ERROR   2004-06-10 12:14:29.561 [flow    ] (): I'm about to call
>>cocoon.sendPageAndWait()
>>ERROR   2004-06-10 12:14:29.632 [flow    ] (): I'm in postpipeline code
>>ERROR   2004-06-10 12:14:29.632 [flow    ] (): I'm inside catch(return)
>>Hibernate: select statushist0_.status as status__, statushist0_.date as
>>    
>>
>
>  
>
>>date__, statushist0_.docId as docId__ from Introspec_History 
>>statushist0_ where statushist0_.docId=? order by statushist0_.date desc
>>Hibernate: select introspecs0_.id as id0_, introspecs0_.code as code0_ 
>>    
>>
>>from Introspec_Status introspecs0_ where introspecs0_.id=?
>  
>
>>Hibernate: select statushist0_.status as status__, statushist0_.date as
>>    
>>
>
>  
>
>>date__, statushist0_.docId as docId__ from Introspec_History 
>>statushist0_ where statushist0_.docId=? order by statushist0_.date desc
>>Hibernate: select statushist0_.status as status__, statushist0_.date as
>>    
>>
>
>  
>
>>date__, statushist0_.docId as docId__ from Introspec_History 
>>statushist0_ where statushist0_.docId=? order by statushist0_.date desc
>>Hibernate: select statushist0_.status as status__, statushist0_.date as
>>    
>>
>
>  
>
>>date__, statushist0_.docId as docId__ from Introspec_History 
>>statushist0_ where statushist0_.docId=? order by statushist0_.date desc
>>Hibernate: select statushist0_.status as status__, statushist0_.date as
>>    
>>
>
>  
>
>>date__, statushist0_.docId as docId__ from Introspec_History 
>>statushist0_ where statushist0_.docId=? order by statushist0_.date desc
>>Hibernate: select statushist0_.status as status__, statushist0_.date as
>>    
>>
>
>  
>
>>date__, statushist0_.docId as docId__ from Introspec_History 
>>statushist0_ where statushist0_.docId=? order by statushist0_.date desc
>>Hibernate: select statushist0_.status as status__, statushist0_.date as
>>    
>>
>
>  
>
>>date__, statushist0_.docId as docId__ from Introspec_History 
>>statushist0_ where statushist0_.docId=? order by statushist0_.date desc
>>Hibernate: select statushist0_.status as status__, statushist0_.date as
>>    
>>
>
>  
>
>>date__, statushist0_.docId as docId__ from Introspec_History 
>>statushist0_ where statushist0_.docId=? order by statushist0_.date desc
>>Hibernate: select statushist0_.status as status__, statushist0_.date as
>>    
>>
>
>  
>
>>date__, statushist0_.docId as docId__ from Introspec_History 
>>statushist0_ where statushist0_.docId=? order by statushist0_.date desc
>>
>>You can clearly see the hibernate request being executed after passing 
>>through both postpipeline and catch(return) blocks.
>>
>>Looking back at 
>>http://wiki.cocoondev.org/Wiki.jsp?page=RhinoWithContinuations, it 
>>seems obvious that catch(return) is only used with continuation objects
>>    
>>
>
>  
>
>>so it's ignored when calling sendPage().
>>
>>But I think this is quite ambiguous:
>>
>> 
>>
>>    
>>
>>>If you want to execute Flowscript code after calling the view layer 
>>>but
>>>   
>>>
>>>      
>>>
>>before control
>> 
>>
>>    
>>
>>>leaves the interpreter, catch(return) will help
>>>   
>>>
>>>      
>>>
>>If "after calling the view layer" means "just after calling the view 
>>layer, but before it's completed", I can't see any use for this 
>>feature.
>>
>>So far, it looks like there's no way to know when the view pipeline is 
>>completed, maybe this is to avoid problems if the view "re-entered" the
>>    
>>
>
>  
>
>>flow (just guessing) ?
>>
>>Finally, I'd like to know if anyone can confirm what I'm reporting (I'm
>>    
>>
>
>  
>
>>running in a minimal cocoon environment and it's not impossible that I 
>>removed some needed components...) ?
>>
>>Thanks,
>>
>>Nicolas.
>>
>>
>>-----Original Message-----
>>From: Leszek Gawron [mailto:lgawron@mobilebox.pl]
>>Sent: 10 juin, 2004 05:37
>>To: users@cocoon.apache.org
>>Subject: Re: Flow + Hibernate and lazy initialization
>>
>>
>>Leszek Gawron wrote:
>> 
>>
>>    
>>
>>>>Well, I cannot see why the releasing cannot be done in the Javascript
>>>>        
>>>>
>
>  
>
>>>>statement following the sendPage... assuming the behaviour you 
>>>>observed was not just a bug in the Flowscript component, of course.
>>>>     
>>>>
>>>>        
>>>>
>>>If this is as you say you should raise this problem at cocoon-dev. I 
>>>also wanted to loose Open Session In View pattern in favor of some 
>>>hibernate avalon component, but that looks impossible now.
>>>   
>>>
>>>      
>>>
>>See this[1], and this[2] and this[3] and this[4]
>>
>>[1] http://marc.theaimsgroup.com/?t=108681937800001&r=1&w=2&n=2
>>[2] 
>>http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=105825181219265&w=2
>>[3]
>>    
>>
>http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=105825410721036&w=2
>  
>
>>[4] http://wiki.cocoondev.org/Wiki.jsp?page=RhinoWithContinuations
>>	LG
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>>For additional commands, e-mail: users-help@cocoon.apache.org
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>>For additional commands, e-mail: users-help@cocoon.apache.org
>>
>>
>> 
>>
>>    
>>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>For additional commands, e-mail: users-help@cocoon.apache.org
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>For additional commands, e-mail: users-help@cocoon.apache.org
>
>
>  
>



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


RE: Flow + Hibernate and lazy initialization

Posted by Nicolas Bielza <ni...@alligacom.com>.
My current flow looks much like this, except I placed a
cocoon.log.error() call in the catch(return) and I can't see anything
logged, I also tried to place a breakpoint in the flowscript debugger
and the code was skipped. I'm afraid the session is simply never closed,
which is of course another solution (there will only be some hibernate
warnings when the unclosed sessions get garbage collected).

My understanding of
http://wiki.cocoondev.org/Wiki.jsp?page=RhinoWithContinuations is that
catch(return) will only be interpreted when a continuation object has
been captured so it is useless with sendPage(). (or was this changed in
2.1.5 ?)

Regards,
Nicolas.

PS: I posted a sample flowscript along with console output somewhere up
this thread.

-----Original Message-----
From: Upayavira [mailto:uv@upaya.co.uk] 
Sent: 10 juin, 2004 15:14
To: users@cocoon.apache.org
Subject: Re: Flow + Hibernate and lazy initialization


Nicolas Bielza wrote:

>Thanks, but I can't think of any more testing to do..
>
>I wanted to use sendPage() since there really is no need for 
>continuation in my flow..
>
>If I use sendPageAndWait() and log something in the catch(return), I 
>can see that the lasy initialization is executed after that (and if I 
>close the session in the catch(return), I can see that the lazy 
>initialization fails).
>
>Maybe "someone"'s code did not use lazy collections ?
>  
>
He assures me he does.

>The fix I'm using now is to fetch lazy collections elements in my 
>query.
>
Here's a cut down sample of some of his working code:
 function scenario () {
   var factory = cocoon.getComponent (PersistanceFactory.ROLE);
   var session = factory.createSession ();
   try {
     var scenario = MyObj.load (session, new java.lang.Long (something),

null);
     cocoon.sendPage (cocoon.parameters["screen"], { scenario: scenario
});
     catch (return) { session.close(); } // the page has finished
rendering
   } catch (e) {
     cocoon.log.error (e);
     cocoon.sendPage("screen/error", {message: 
"scenarios.scenario.notavailable"});
     session.close();
   } finally {
     cocoon.releaseComponent(factory);
   }
 }
 
How does yours match? Could you post it?

Regards, Upayavira

>-----Original Message-----
>From: Upayavira [mailto:uv@upaya.co.uk]
>Sent: 10 juin, 2004 14:50
>To: users@cocoon.apache.org
>Subject: Re: Flow + Hibernate and lazy initialization
>
>
>Nicolas Bielza wrote:
>
>  
>
>>Thanks, I tried this and the catch(return) is not interpreted when
>>using sendPage(), it's just ignored.
>>
>>I also tried your previous suggestion, but my app was not responding
>>anymore, maybe the "FOM_Cocoon.suicide();" line is required ?
>>
>>Anyway, this probably won't help much, since I also tried the
>>postpipeline code with sendPageAndWait() and it's also  interpreted 
>>before the view is rendered. This looks like a bug : The 
>>http://cocoon.apache.org/2.1/userdocs/flow/api.html#sendPageAndWait
>>page says :
>>
>>"If provided, the postPipelineCode function will be executed after
>>pipeline processing is complete but before the script is suspended.
You
>>    
>>
>
>  
>
>>can use this to release resources that are needed during the pipeline
>>processing but should not become part of the continuation"
>>
>>If the "catch(return)" code is interpreted just before the script is
>>suspended, then it looks like the script is suspended BEFORE the 
>>pipeline processing is complete ! So the postpipeline code is really a

>>postpipelineinvocation code.
>>
>>It looks like the only solution that would work is to use a filter
>>servlet but I don't have such things in my environment :(
>> 
>>
>>    
>>
>I'd say persevere with the catch(return) idea. The reason I proposed it
>is because I asked someone who had exactly that problem with Hibernate,

>and it works for him. And he was advised by the person who coded a lot 
>of the flow stuff.
>
>Regards, Upayavira
>
>  
>
>>Regards,
>>
>>Nicolas.
>>
>>-----Original Message-----
>>From: Upayavira [mailto:uv@upaya.co.uk]
>>Sent: 10 juin, 2004 14:14
>>To: users@cocoon.apache.org
>>Subject: Re: Flow + Hibernate and lazy initialization
>>
>>
>>Nicolas Bielza wrote:
>>
>> 
>>
>>    
>>
>>>Well, when I say that they "work", I mean that they are interpreted
>>>and
>>>   
>>>
>>>      
>>>
>> 
>>
>>    
>>
>>>not ignored. I'm not sure that they actually "work", since they don't

>>>seem to wait for the view to be rendered. (but maybe this is by
>>>design..)
>>>
>>>   
>>>
>>>      
>>>
>>Try this:
>>
>>function someFunction() {
>>
>>   var session = ...
>>   ...
>>
>>   cocoon.sendPage(...);
>>
>>   catch (return) {
>>       // after calling the view layer but before control 
>>       // leaves the interpreter
>>   }
>>}
>>
>>Note, the catch is not associated with a try.
>>
>>This came of the previously referenced 
>>http://wiki.cocoondev.org/Wiki.jsp?page=RhinoWithContinuations
>>but that page is pretty frightening.
>>
>>Hope this helps.
>>
>>Regards, Upayavira
>>    
>>




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


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


Re: Flow + Hibernate and lazy initialization

Posted by Upayavira <uv...@upaya.co.uk>.
Nicolas Bielza wrote:

>Thanks, but I can't think of any more testing to do..
>
>I wanted to use sendPage() since there really is no need for
>continuation in my flow..
>
>If I use sendPageAndWait() and log something in the catch(return), I can
>see that the lasy initialization is executed after that (and if I close
>the session in the catch(return), I can see that the lazy initialization
>fails).
>
>Maybe "someone"'s code did not use lazy collections ?
>  
>
He assures me he does.

>The fix I'm using now is to fetch lazy collections elements in my query.
>
Here's a cut down sample of some of his working code:
 function scenario () {
   var factory = cocoon.getComponent (PersistanceFactory.ROLE);
   var session = factory.createSession ();
   try {
     var scenario = MyObj.load (session, new java.lang.Long (something), 
null);
     cocoon.sendPage (cocoon.parameters["screen"], { scenario: scenario });
     catch (return) { session.close(); } // the page has finished rendering
   } catch (e) {
     cocoon.log.error (e);
     cocoon.sendPage("screen/error", {message: 
"scenarios.scenario.notavailable"});
     session.close();
   } finally {
     cocoon.releaseComponent(factory);
   }
 }
 
How does yours match? Could you post it?

Regards, Upayavira

>-----Original Message-----
>From: Upayavira [mailto:uv@upaya.co.uk] 
>Sent: 10 juin, 2004 14:50
>To: users@cocoon.apache.org
>Subject: Re: Flow + Hibernate and lazy initialization
>
>
>Nicolas Bielza wrote:
>
>  
>
>>Thanks, I tried this and the catch(return) is not interpreted when 
>>using sendPage(), it's just ignored.
>>
>>I also tried your previous suggestion, but my app was not responding 
>>anymore, maybe the "FOM_Cocoon.suicide();" line is required ?
>>
>>Anyway, this probably won't help much, since I also tried the 
>>postpipeline code with sendPageAndWait() and it's also  interpreted 
>>before the view is rendered. This looks like a bug : The 
>>http://cocoon.apache.org/2.1/userdocs/flow/api.html#sendPageAndWait
>>page says :
>>
>>"If provided, the postPipelineCode function will be executed after 
>>pipeline processing is complete but before the script is suspended. You
>>    
>>
>
>  
>
>>can use this to release resources that are needed during the pipeline 
>>processing but should not become part of the continuation"
>>
>>If the "catch(return)" code is interpreted just before the script is 
>>suspended, then it looks like the script is suspended BEFORE the 
>>pipeline processing is complete ! So the postpipeline code is really a 
>>postpipelineinvocation code.
>>
>>It looks like the only solution that would work is to use a filter 
>>servlet but I don't have such things in my environment :(
>> 
>>
>>    
>>
>I'd say persevere with the catch(return) idea. The reason I proposed it 
>is because I asked someone who had exactly that problem with Hibernate, 
>and it works for him. And he was advised by the person who coded a lot 
>of the flow stuff.
>
>Regards, Upayavira
>
>  
>
>>Regards,
>>
>>Nicolas.
>>
>>-----Original Message-----
>>From: Upayavira [mailto:uv@upaya.co.uk]
>>Sent: 10 juin, 2004 14:14
>>To: users@cocoon.apache.org
>>Subject: Re: Flow + Hibernate and lazy initialization
>>
>>
>>Nicolas Bielza wrote:
>>
>> 
>>
>>    
>>
>>>Well, when I say that they "work", I mean that they are interpreted 
>>>and
>>>   
>>>
>>>      
>>>
>> 
>>
>>    
>>
>>>not ignored. I'm not sure that they actually "work", since they don't
>>>seem to wait for the view to be rendered. (but maybe this is by
>>>design..)
>>>
>>>   
>>>
>>>      
>>>
>>Try this:
>>
>>function someFunction() {
>>
>>   var session = ...
>>   ...
>>
>>   cocoon.sendPage(...);
>>
>>   catch (return) {
>>       // after calling the view layer but before control 
>>       // leaves the interpreter
>>   }
>>}
>>
>>Note, the catch is not associated with a try.
>>
>>This came of the previously referenced
>>http://wiki.cocoondev.org/Wiki.jsp?page=RhinoWithContinuations
>>but that page is pretty frightening.
>>
>>Hope this helps.
>>
>>Regards, Upayavira
>>    
>>




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


RE: Flow + Hibernate and lazy initialization

Posted by Nicolas Bielza <ni...@alligacom.com>.
Thanks, but I can't think of any more testing to do..

I wanted to use sendPage() since there really is no need for
continuation in my flow..

If I use sendPageAndWait() and log something in the catch(return), I can
see that the lasy initialization is executed after that (and if I close
the session in the catch(return), I can see that the lazy initialization
fails).

Maybe "someone"'s code did not use lazy collections ?

The fix I'm using now is to fetch lazy collections elements in my query.

Regards,
Nicolas.

-----Original Message-----
From: Upayavira [mailto:uv@upaya.co.uk] 
Sent: 10 juin, 2004 14:50
To: users@cocoon.apache.org
Subject: Re: Flow + Hibernate and lazy initialization


Nicolas Bielza wrote:

>Thanks, I tried this and the catch(return) is not interpreted when 
>using sendPage(), it's just ignored.
>
>I also tried your previous suggestion, but my app was not responding 
>anymore, maybe the "FOM_Cocoon.suicide();" line is required ?
>
>Anyway, this probably won't help much, since I also tried the 
>postpipeline code with sendPageAndWait() and it's also  interpreted 
>before the view is rendered. This looks like a bug : The 
>http://cocoon.apache.org/2.1/userdocs/flow/api.html#sendPageAndWait
>page says :
>
>"If provided, the postPipelineCode function will be executed after 
>pipeline processing is complete but before the script is suspended. You

>can use this to release resources that are needed during the pipeline 
>processing but should not become part of the continuation"
>
>If the "catch(return)" code is interpreted just before the script is 
>suspended, then it looks like the script is suspended BEFORE the 
>pipeline processing is complete ! So the postpipeline code is really a 
>postpipelineinvocation code.
>
>It looks like the only solution that would work is to use a filter 
>servlet but I don't have such things in my environment :(
>  
>
I'd say persevere with the catch(return) idea. The reason I proposed it 
is because I asked someone who had exactly that problem with Hibernate, 
and it works for him. And he was advised by the person who coded a lot 
of the flow stuff.

Regards, Upayavira

>Regards,
>
>Nicolas.
>
>-----Original Message-----
>From: Upayavira [mailto:uv@upaya.co.uk]
>Sent: 10 juin, 2004 14:14
>To: users@cocoon.apache.org
>Subject: Re: Flow + Hibernate and lazy initialization
>
>
>Nicolas Bielza wrote:
>
>  
>
>>Well, when I say that they "work", I mean that they are interpreted 
>>and
>>    
>>
>
>  
>
>>not ignored. I'm not sure that they actually "work", since they don't
>>seem to wait for the view to be rendered. (but maybe this is by
>>design..)
>>
>>    
>>
>
>Try this:
>
>function someFunction() {
>
>    var session = ...
>    ...
>
>    cocoon.sendPage(...);
>
>    catch (return) {
>        // after calling the view layer but before control 
>        // leaves the interpreter
>    }
>}
>
>Note, the catch is not associated with a try.
>
>This came of the previously referenced
>http://wiki.cocoondev.org/Wiki.jsp?page=RhinoWithContinuations
>but that page is pretty frightening.
>
>Hope this helps.
>
>Regards, Upayavira
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>For additional commands, e-mail: users-help@cocoon.apache.org
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>For additional commands, e-mail: users-help@cocoon.apache.org
>
>
>  
>



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


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


Re: Flow + Hibernate and lazy initialization

Posted by Upayavira <uv...@upaya.co.uk>.
Nicolas Bielza wrote:

>Thanks, I tried this and the catch(return) is not interpreted when using
>sendPage(), it's just ignored.
>
>I also tried your previous suggestion, but my app was not responding
>anymore, maybe the "FOM_Cocoon.suicide();" line is required ?
>
>Anyway, this probably won't help much, since I also tried the
>postpipeline code with sendPageAndWait() and it's also  interpreted
>before the view is rendered. This looks like a bug :
>The http://cocoon.apache.org/2.1/userdocs/flow/api.html#sendPageAndWait
>page says :
>
>"If provided, the postPipelineCode function will be executed after
>pipeline processing is complete but before the script is suspended. You
>can use this to release resources that are needed during the pipeline
>processing but should not become part of the continuation"
>
>If the "catch(return)" code is interpreted just before the script is
>suspended, then it looks like the script is suspended BEFORE the
>pipeline processing is complete ! So the postpipeline code is really a
>postpipelineinvocation code.
>
>It looks like the only solution that would work is to use a filter
>servlet but I don't have such things in my environment :(
>  
>
I'd say persevere with the catch(return) idea. The reason I proposed it 
is because I asked someone who had exactly that problem with Hibernate, 
and it works for him. And he was advised by the person who coded a lot 
of the flow stuff.

Regards, Upayavira

>Regards,
>
>Nicolas.
>
>-----Original Message-----
>From: Upayavira [mailto:uv@upaya.co.uk] 
>Sent: 10 juin, 2004 14:14
>To: users@cocoon.apache.org
>Subject: Re: Flow + Hibernate and lazy initialization
>
>
>Nicolas Bielza wrote:
>
>  
>
>>Well, when I say that they "work", I mean that they are interpreted and
>>    
>>
>
>  
>
>>not ignored. I'm not sure that they actually "work", since they don't 
>>seem to wait for the view to be rendered. (but maybe this is by
>>design..)
>>
>>    
>>
>
>Try this:
>
>function someFunction() {
>
>    var session = ...
>    ...
>
>    cocoon.sendPage(...);
>
>    catch (return) {
>        // after calling the view layer but before control 
>        // leaves the interpreter
>    }
>}
>
>Note, the catch is not associated with a try.
>
>This came of the previously referenced 
>http://wiki.cocoondev.org/Wiki.jsp?page=RhinoWithContinuations
>but that page is pretty frightening.
>
>Hope this helps.
>
>Regards, Upayavira
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>For additional commands, e-mail: users-help@cocoon.apache.org
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>For additional commands, e-mail: users-help@cocoon.apache.org
>
>
>  
>



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


RE: Flow + Hibernate and lazy initialization

Posted by Nicolas Bielza <ni...@alligacom.com>.
Thanks, I tried this and the catch(return) is not interpreted when using
sendPage(), it's just ignored.

I also tried your previous suggestion, but my app was not responding
anymore, maybe the "FOM_Cocoon.suicide();" line is required ?

Anyway, this probably won't help much, since I also tried the
postpipeline code with sendPageAndWait() and it's also  interpreted
before the view is rendered. This looks like a bug :
The http://cocoon.apache.org/2.1/userdocs/flow/api.html#sendPageAndWait
page says :

"If provided, the postPipelineCode function will be executed after
pipeline processing is complete but before the script is suspended. You
can use this to release resources that are needed during the pipeline
processing but should not become part of the continuation"

If the "catch(return)" code is interpreted just before the script is
suspended, then it looks like the script is suspended BEFORE the
pipeline processing is complete ! So the postpipeline code is really a
postpipelineinvocation code.

It looks like the only solution that would work is to use a filter
servlet but I don't have such things in my environment :(

Regards,

Nicolas.

-----Original Message-----
From: Upayavira [mailto:uv@upaya.co.uk] 
Sent: 10 juin, 2004 14:14
To: users@cocoon.apache.org
Subject: Re: Flow + Hibernate and lazy initialization


Nicolas Bielza wrote:

>Well, when I say that they "work", I mean that they are interpreted and

>not ignored. I'm not sure that they actually "work", since they don't 
>seem to wait for the view to be rendered. (but maybe this is by
>design..)
>

Try this:

function someFunction() {

    var session = ...
    ...

    cocoon.sendPage(...);

    catch (return) {
        // after calling the view layer but before control 
        // leaves the interpreter
    }
}

Note, the catch is not associated with a try.

This came of the previously referenced 
http://wiki.cocoondev.org/Wiki.jsp?page=RhinoWithContinuations
but that page is pretty frightening.

Hope this helps.

Regards, Upayavira



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


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


Re: Flow + Hibernate and lazy initialization

Posted by Upayavira <uv...@upaya.co.uk>.
Nicolas Bielza wrote:

>Well, when I say that they "work", I mean that they are interpreted and
>not ignored. I'm not sure that they actually "work", since they don't
>seem to wait for the view to be rendered. (but maybe this is by
>design..)
>

Try this:

function someFunction() {

    var session = ...
    ...

    cocoon.sendPage(...);

    catch (return) {
        // after calling the view layer but before control 
        // leaves the interpreter
    }
}

Note, the catch is not associated with a try.

This came of the previously referenced 
http://wiki.cocoondev.org/Wiki.jsp?page=RhinoWithContinuations
but that page is pretty frightening.

Hope this helps.

Regards, Upayavira



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


RE: Flow + Hibernate and lazy initialization

Posted by Nicolas Bielza <ni...@alligacom.com>.
Well, when I say that they "work", I mean that they are interpreted and
not ignored. I'm not sure that they actually "work", since they don't
seem to wait for the view to be rendered. (but maybe this is by
design..)

-----Original Message-----
From: Nicolas Bielza [mailto:nicolas.bielza@alligacom.com] 
Sent: 10 juin, 2004 13:32
To: users@cocoon.apache.org
Subject: RE: Flow + Hibernate and lazy initialization


No, sendPageAndWait() does this. I think maybe catch(return) and the
postpipeline function are the same thing. Anyway I tested both and they
only work when using sendPageAndWait(), that is, when a continuation
object is created. (This is consistent with the doc).

Nicolas.

-----Original Message-----
From: Upayavira [mailto:uv@upaya.co.uk] 
Sent: 10 juin, 2004 13:19
To: users@cocoon.apache.org
Subject: Re: Flow + Hibernate and lazy initialization


Nicolas Bielza wrote:

>I tried to use the catch(return) trick but it doesn't seem to work.
>(I'm using cocoon 2.1.4)
>  
>
Never used it, but - doesn't the cocoon.sendPage("url", {"foo":foo}, 
function(){hibernateSession.close();});
syntax do this?

Upayavira

>I added some log messages in the flowscript and it seems that the
>catch(return) is not executed when I call sendPage() (the script
>debugger also exposed this, and after a while, I started to see some 
>warnings about unclosed sessions...).
>
>I tried with sendPageAndWait() and this time the catch(return) got
>executed, but it was called before the pipeline completed: I still had 
>lazy initialization exceptions during pipeline processing.
>
>I also tried to close the session in the postpipeline code (when using
>sendPageAndWait()) and again, the session was closed before pipeline
>completed.
>
>Here's an example flowscript (I'm not closing the session here, just
>logging) :
>
>try {
>
>  // ...
>
>  var list = query.list();
>  cocoon.log.error("I'm about to call cocoon.sendPageAndWait()");
>  cocoon.sendPageAndWait("report.vm", {"list" : new HashSet(list)},
>function() { cocoon.log.error("I'm in postpipeline code"); }, 0);
>  catch(return) {
>    cocoon.log.error("I'm inside catch(return)");
>  }
>}
>finally {
>  cocoon.log.error("I'm inside finally block");
>  //clean up
>  cocoon.releaseComponent(hibernateFactory);
>}
>
>
>Now, here's the console output:
>
>Hibernate: select introspecd0_.id as id, introspecd0_.envelop as
>envelop, introspecd0_.reference as reference, 
>introspecd0_.tradingPartner as tradingP4_, introspecd0_.docType as 
>docType from Introspec_Document introspecd0_ inner join 
>Introspec_History statushist1_ on introspecd0_.id=statushist1_.docId
>Hibernate: select introspecd0_.id as id0_, introspecd0_.name as name0_ 
>from Introspec_DocType introspecd0_ where introspecd0_.id=?
>ERROR   2004-06-10 12:14:29.561 [flow    ] (): I'm about to call
>cocoon.sendPageAndWait()
>ERROR   2004-06-10 12:14:29.632 [flow    ] (): I'm in postpipeline code
>ERROR   2004-06-10 12:14:29.632 [flow    ] (): I'm inside catch(return)
>Hibernate: select statushist0_.status as status__, statushist0_.date as

>date__, statushist0_.docId as docId__ from Introspec_History
>statushist0_ where statushist0_.docId=? order by statushist0_.date desc
>Hibernate: select introspecs0_.id as id0_, introspecs0_.code as code0_ 
>from Introspec_Status introspecs0_ where introspecs0_.id=?
>Hibernate: select statushist0_.status as status__, statushist0_.date as

>date__, statushist0_.docId as docId__ from Introspec_History
>statushist0_ where statushist0_.docId=? order by statushist0_.date desc
>Hibernate: select statushist0_.status as status__, statushist0_.date as

>date__, statushist0_.docId as docId__ from Introspec_History
>statushist0_ where statushist0_.docId=? order by statushist0_.date desc
>Hibernate: select statushist0_.status as status__, statushist0_.date as

>date__, statushist0_.docId as docId__ from Introspec_History
>statushist0_ where statushist0_.docId=? order by statushist0_.date desc
>Hibernate: select statushist0_.status as status__, statushist0_.date as

>date__, statushist0_.docId as docId__ from Introspec_History
>statushist0_ where statushist0_.docId=? order by statushist0_.date desc
>Hibernate: select statushist0_.status as status__, statushist0_.date as

>date__, statushist0_.docId as docId__ from Introspec_History
>statushist0_ where statushist0_.docId=? order by statushist0_.date desc
>Hibernate: select statushist0_.status as status__, statushist0_.date as

>date__, statushist0_.docId as docId__ from Introspec_History
>statushist0_ where statushist0_.docId=? order by statushist0_.date desc
>Hibernate: select statushist0_.status as status__, statushist0_.date as

>date__, statushist0_.docId as docId__ from Introspec_History
>statushist0_ where statushist0_.docId=? order by statushist0_.date desc
>Hibernate: select statushist0_.status as status__, statushist0_.date as

>date__, statushist0_.docId as docId__ from Introspec_History
>statushist0_ where statushist0_.docId=? order by statushist0_.date desc
>
>You can clearly see the hibernate request being executed after passing
>through both postpipeline and catch(return) blocks.
>
>Looking back at
>http://wiki.cocoondev.org/Wiki.jsp?page=RhinoWithContinuations, it 
>seems obvious that catch(return) is only used with continuation objects

>so it's ignored when calling sendPage().
>
>But I think this is quite ambiguous:
>
>  
>
>>If you want to execute Flowscript code after calling the view layer
>>but
>>    
>>
>before control
>  
>
>>leaves the interpreter, catch(return) will help
>>    
>>
>
>If "after calling the view layer" means "just after calling the view
>layer, but before it's completed", I can't see any use for this 
>feature.
>
>So far, it looks like there's no way to know when the view pipeline is
>completed, maybe this is to avoid problems if the view "re-entered" the

>flow (just guessing) ?
>
>Finally, I'd like to know if anyone can confirm what I'm reporting (I'm

>running in a minimal cocoon environment and it's not impossible that I
>removed some needed components...) ?
>
>Thanks,
>
>Nicolas.
>
>
>-----Original Message-----
>From: Leszek Gawron [mailto:lgawron@mobilebox.pl]
>Sent: 10 juin, 2004 05:37
>To: users@cocoon.apache.org
>Subject: Re: Flow + Hibernate and lazy initialization
>
>
>Leszek Gawron wrote:
>  
>
>>>Well, I cannot see why the releasing cannot be done in the Javascript

>>>statement following the sendPage... assuming the behaviour you
>>>observed was not just a bug in the Flowscript component, of course.
>>>      
>>>
>>If this is as you say you should raise this problem at cocoon-dev. I
>>also wanted to loose Open Session In View pattern in favor of some 
>>hibernate avalon component, but that looks impossible now.
>>    
>>
>See this[1], and this[2] and this[3] and this[4]
>
>[1] http://marc.theaimsgroup.com/?t=108681937800001&r=1&w=2&n=2
>[2]
>http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=105825181219265&w=2
>[3]
http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=105825410721036&w=2
>[4] http://wiki.cocoondev.org/Wiki.jsp?page=RhinoWithContinuations
>	LG
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>For additional commands, e-mail: users-help@cocoon.apache.org
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>For additional commands, e-mail: users-help@cocoon.apache.org
>
>
>  
>



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


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


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


RE: Flow + Hibernate and lazy initialization

Posted by Nicolas Bielza <ni...@alligacom.com>.
No, sendPageAndWait() does this. I think maybe catch(return) and the
postpipeline function are the same thing. Anyway I tested both and they
only work when using sendPageAndWait(), that is, when a continuation
object is created. (This is consistent with the doc).

Nicolas.

-----Original Message-----
From: Upayavira [mailto:uv@upaya.co.uk] 
Sent: 10 juin, 2004 13:19
To: users@cocoon.apache.org
Subject: Re: Flow + Hibernate and lazy initialization


Nicolas Bielza wrote:

>I tried to use the catch(return) trick but it doesn't seem to work. 
>(I'm using cocoon 2.1.4)
>  
>
Never used it, but - doesn't the cocoon.sendPage("url", {"foo":foo}, 
function(){hibernateSession.close();});
syntax do this?

Upayavira

>I added some log messages in the flowscript and it seems that the
>catch(return) is not executed when I call sendPage() (the script 
>debugger also exposed this, and after a while, I started to see some 
>warnings about unclosed sessions...).
>
>I tried with sendPageAndWait() and this time the catch(return) got 
>executed, but it was called before the pipeline completed: I still had 
>lazy initialization exceptions during pipeline processing.
>
>I also tried to close the session in the postpipeline code (when using
>sendPageAndWait()) and again, the session was closed before pipeline 
>completed.
>
>Here's an example flowscript (I'm not closing the session here, just
>logging) :
>
>try {
>
>  // ...
>
>  var list = query.list();
>  cocoon.log.error("I'm about to call cocoon.sendPageAndWait()");
>  cocoon.sendPageAndWait("report.vm", {"list" : new HashSet(list)},
>function() { cocoon.log.error("I'm in postpipeline code"); }, 0);
>  catch(return) {
>    cocoon.log.error("I'm inside catch(return)");
>  }
>}
>finally {
>  cocoon.log.error("I'm inside finally block");
>  //clean up
>  cocoon.releaseComponent(hibernateFactory);
>}
>
>
>Now, here's the console output:
>
>Hibernate: select introspecd0_.id as id, introspecd0_.envelop as 
>envelop, introspecd0_.reference as reference, 
>introspecd0_.tradingPartner as tradingP4_, introspecd0_.docType as 
>docType from Introspec_Document introspecd0_ inner join 
>Introspec_History statushist1_ on introspecd0_.id=statushist1_.docId
>Hibernate: select introspecd0_.id as id0_, introspecd0_.name as name0_ 
>from Introspec_DocType introspecd0_ where introspecd0_.id=?
>ERROR   2004-06-10 12:14:29.561 [flow    ] (): I'm about to call
>cocoon.sendPageAndWait()
>ERROR   2004-06-10 12:14:29.632 [flow    ] (): I'm in postpipeline code
>ERROR   2004-06-10 12:14:29.632 [flow    ] (): I'm inside catch(return)
>Hibernate: select statushist0_.status as status__, statushist0_.date as

>date__, statushist0_.docId as docId__ from Introspec_History 
>statushist0_ where statushist0_.docId=? order by statushist0_.date desc
>Hibernate: select introspecs0_.id as id0_, introspecs0_.code as code0_ 
>from Introspec_Status introspecs0_ where introspecs0_.id=?
>Hibernate: select statushist0_.status as status__, statushist0_.date as

>date__, statushist0_.docId as docId__ from Introspec_History 
>statushist0_ where statushist0_.docId=? order by statushist0_.date desc
>Hibernate: select statushist0_.status as status__, statushist0_.date as

>date__, statushist0_.docId as docId__ from Introspec_History 
>statushist0_ where statushist0_.docId=? order by statushist0_.date desc
>Hibernate: select statushist0_.status as status__, statushist0_.date as

>date__, statushist0_.docId as docId__ from Introspec_History 
>statushist0_ where statushist0_.docId=? order by statushist0_.date desc
>Hibernate: select statushist0_.status as status__, statushist0_.date as

>date__, statushist0_.docId as docId__ from Introspec_History 
>statushist0_ where statushist0_.docId=? order by statushist0_.date desc
>Hibernate: select statushist0_.status as status__, statushist0_.date as

>date__, statushist0_.docId as docId__ from Introspec_History 
>statushist0_ where statushist0_.docId=? order by statushist0_.date desc
>Hibernate: select statushist0_.status as status__, statushist0_.date as

>date__, statushist0_.docId as docId__ from Introspec_History 
>statushist0_ where statushist0_.docId=? order by statushist0_.date desc
>Hibernate: select statushist0_.status as status__, statushist0_.date as

>date__, statushist0_.docId as docId__ from Introspec_History 
>statushist0_ where statushist0_.docId=? order by statushist0_.date desc
>Hibernate: select statushist0_.status as status__, statushist0_.date as

>date__, statushist0_.docId as docId__ from Introspec_History 
>statushist0_ where statushist0_.docId=? order by statushist0_.date desc
>
>You can clearly see the hibernate request being executed after passing 
>through both postpipeline and catch(return) blocks.
>
>Looking back at 
>http://wiki.cocoondev.org/Wiki.jsp?page=RhinoWithContinuations, it 
>seems obvious that catch(return) is only used with continuation objects

>so it's ignored when calling sendPage().
>
>But I think this is quite ambiguous:
>
>  
>
>>If you want to execute Flowscript code after calling the view layer 
>>but
>>    
>>
>before control
>  
>
>>leaves the interpreter, catch(return) will help
>>    
>>
>
>If "after calling the view layer" means "just after calling the view 
>layer, but before it's completed", I can't see any use for this 
>feature.
>
>So far, it looks like there's no way to know when the view pipeline is 
>completed, maybe this is to avoid problems if the view "re-entered" the

>flow (just guessing) ?
>
>Finally, I'd like to know if anyone can confirm what I'm reporting (I'm

>running in a minimal cocoon environment and it's not impossible that I 
>removed some needed components...) ?
>
>Thanks,
>
>Nicolas.
>
>
>-----Original Message-----
>From: Leszek Gawron [mailto:lgawron@mobilebox.pl]
>Sent: 10 juin, 2004 05:37
>To: users@cocoon.apache.org
>Subject: Re: Flow + Hibernate and lazy initialization
>
>
>Leszek Gawron wrote:
>  
>
>>>Well, I cannot see why the releasing cannot be done in the Javascript

>>>statement following the sendPage... assuming the behaviour you 
>>>observed was not just a bug in the Flowscript component, of course.
>>>      
>>>
>>If this is as you say you should raise this problem at cocoon-dev. I 
>>also wanted to loose Open Session In View pattern in favor of some 
>>hibernate avalon component, but that looks impossible now.
>>    
>>
>See this[1], and this[2] and this[3] and this[4]
>
>[1] http://marc.theaimsgroup.com/?t=108681937800001&r=1&w=2&n=2
>[2] 
>http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=105825181219265&w=2
>[3]
http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=105825410721036&w=2
>[4] http://wiki.cocoondev.org/Wiki.jsp?page=RhinoWithContinuations
>	LG
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>For additional commands, e-mail: users-help@cocoon.apache.org
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>For additional commands, e-mail: users-help@cocoon.apache.org
>
>
>  
>



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


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


Re: Flow + Hibernate and lazy initialization

Posted by Upayavira <uv...@upaya.co.uk>.
Nicolas Bielza wrote:

>I tried to use the catch(return) trick but it doesn't seem to work. (I'm
>using cocoon 2.1.4)
>  
>
Never used it, but - doesn't the cocoon.sendPage("url", {"foo":foo}, 
function(){hibernateSession.close();});
syntax do this?

Upayavira

>I added some log messages in the flowscript and it seems that the
>catch(return) is not executed when I call sendPage() (the script
>debugger also exposed this, and after a while, I started to see some
>warnings about unclosed sessions...).
>
>I tried with sendPageAndWait() and this time the catch(return) got
>executed, but it was called before the pipeline completed: I still had
>lazy initialization exceptions during pipeline processing.
>
>I also tried to close the session in the postpipeline code (when using
>sendPageAndWait()) and again, the session was closed before pipeline
>completed.
>
>Here's an example flowscript (I'm not closing the session here, just
>logging) :
>
>try {
>
>  // ...
>
>  var list = query.list();
>  cocoon.log.error("I'm about to call cocoon.sendPageAndWait()");
>  cocoon.sendPageAndWait("report.vm", {"list" : new HashSet(list)},
>function() { cocoon.log.error("I'm in postpipeline code"); }, 0);
>  catch(return) {
>    cocoon.log.error("I'm inside catch(return)");
>  }
>}
>finally {
>  cocoon.log.error("I'm inside finally block");
>  //clean up
>  cocoon.releaseComponent(hibernateFactory);
>}
>
>
>Now, here's the console output:
>
>Hibernate: select introspecd0_.id as id, introspecd0_.envelop as
>envelop, introspecd0_.reference as reference,
>introspecd0_.tradingPartner as tradingP4_, introspecd0_.docType as
>docType from Introspec_Document introspecd0_ inner join
>Introspec_History statushist1_ on introspecd0_.id=statushist1_.docId
>Hibernate: select introspecd0_.id as id0_, introspecd0_.name as name0_
>from Introspec_DocType introspecd0_ where introspecd0_.id=?
>ERROR   2004-06-10 12:14:29.561 [flow    ] (): I'm about to call
>cocoon.sendPageAndWait()
>ERROR   2004-06-10 12:14:29.632 [flow    ] (): I'm in postpipeline code
>ERROR   2004-06-10 12:14:29.632 [flow    ] (): I'm inside catch(return)
>Hibernate: select statushist0_.status as status__, statushist0_.date as
>date__, statushist0_.docId as docId__ from Introspec_History
>statushist0_ where statushist0_.docId=? order by statushist0_.date desc
>Hibernate: select introspecs0_.id as id0_, introspecs0_.code as code0_
>from Introspec_Status introspecs0_ where introspecs0_.id=?
>Hibernate: select statushist0_.status as status__, statushist0_.date as
>date__, statushist0_.docId as docId__ from Introspec_History
>statushist0_ where statushist0_.docId=? order by statushist0_.date desc
>Hibernate: select statushist0_.status as status__, statushist0_.date as
>date__, statushist0_.docId as docId__ from Introspec_History
>statushist0_ where statushist0_.docId=? order by statushist0_.date desc
>Hibernate: select statushist0_.status as status__, statushist0_.date as
>date__, statushist0_.docId as docId__ from Introspec_History
>statushist0_ where statushist0_.docId=? order by statushist0_.date desc
>Hibernate: select statushist0_.status as status__, statushist0_.date as
>date__, statushist0_.docId as docId__ from Introspec_History
>statushist0_ where statushist0_.docId=? order by statushist0_.date desc
>Hibernate: select statushist0_.status as status__, statushist0_.date as
>date__, statushist0_.docId as docId__ from Introspec_History
>statushist0_ where statushist0_.docId=? order by statushist0_.date desc
>Hibernate: select statushist0_.status as status__, statushist0_.date as
>date__, statushist0_.docId as docId__ from Introspec_History
>statushist0_ where statushist0_.docId=? order by statushist0_.date desc
>Hibernate: select statushist0_.status as status__, statushist0_.date as
>date__, statushist0_.docId as docId__ from Introspec_History
>statushist0_ where statushist0_.docId=? order by statushist0_.date desc
>Hibernate: select statushist0_.status as status__, statushist0_.date as
>date__, statushist0_.docId as docId__ from Introspec_History
>statushist0_ where statushist0_.docId=? order by statushist0_.date desc
>
>You can clearly see the hibernate request being executed after passing
>through both postpipeline and catch(return) blocks.
>
>Looking back at
>http://wiki.cocoondev.org/Wiki.jsp?page=RhinoWithContinuations, it seems
>obvious that catch(return) is only used with continuation objects so
>it's ignored when calling sendPage().
>
>But I think this is quite ambiguous:
>
>  
>
>>If you want to execute Flowscript code after calling the view layer but
>>    
>>
>before control
>  
>
>>leaves the interpreter, catch(return) will help
>>    
>>
>
>If "after calling the view layer" means "just after calling the view
>layer, but before it's completed", I can't see any use for this feature.
>
>So far, it looks like there's no way to know when the view pipeline is
>completed, maybe this is to avoid problems if the view "re-entered" the
>flow (just guessing) ?
>
>Finally, I'd like to know if anyone can confirm what I'm reporting (I'm
>running in a minimal cocoon environment and it's not impossible that I
>removed some needed components...) ?
>
>Thanks,
>
>Nicolas.
>
>
>-----Original Message-----
>From: Leszek Gawron [mailto:lgawron@mobilebox.pl] 
>Sent: 10 juin, 2004 05:37
>To: users@cocoon.apache.org
>Subject: Re: Flow + Hibernate and lazy initialization
>
>
>Leszek Gawron wrote:
>  
>
>>>Well, I cannot see why the releasing cannot be done in the Javascript
>>>statement following the sendPage... assuming the behaviour you 
>>>observed was not just a bug in the Flowscript component, of course.
>>>      
>>>
>>If this is as you say you should raise this problem at cocoon-dev. I
>>also wanted to loose Open Session In View pattern in favor of some 
>>hibernate avalon component, but that looks impossible now.
>>    
>>
>See this[1], and this[2] and this[3] and this[4]
>
>[1] http://marc.theaimsgroup.com/?t=108681937800001&r=1&w=2&n=2
>[2] http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=105825181219265&w=2
>[3] http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=105825410721036&w=2
>[4] http://wiki.cocoondev.org/Wiki.jsp?page=RhinoWithContinuations
>	LG
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>For additional commands, e-mail: users-help@cocoon.apache.org
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>For additional commands, e-mail: users-help@cocoon.apache.org
>
>
>  
>



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


RE: Flow + Hibernate and lazy initialization

Posted by Nicolas Bielza <ni...@alligacom.com>.
I tried to use the catch(return) trick but it doesn't seem to work. (I'm
using cocoon 2.1.4)

I added some log messages in the flowscript and it seems that the
catch(return) is not executed when I call sendPage() (the script
debugger also exposed this, and after a while, I started to see some
warnings about unclosed sessions...).

I tried with sendPageAndWait() and this time the catch(return) got
executed, but it was called before the pipeline completed: I still had
lazy initialization exceptions during pipeline processing.

I also tried to close the session in the postpipeline code (when using
sendPageAndWait()) and again, the session was closed before pipeline
completed.

Here's an example flowscript (I'm not closing the session here, just
logging) :

try {

  // ...

  var list = query.list();
  cocoon.log.error("I'm about to call cocoon.sendPageAndWait()");
  cocoon.sendPageAndWait("report.vm", {"list" : new HashSet(list)},
function() { cocoon.log.error("I'm in postpipeline code"); }, 0);
  catch(return) {
    cocoon.log.error("I'm inside catch(return)");
  }
}
finally {
  cocoon.log.error("I'm inside finally block");
  //clean up
  cocoon.releaseComponent(hibernateFactory);
}


Now, here's the console output:

Hibernate: select introspecd0_.id as id, introspecd0_.envelop as
envelop, introspecd0_.reference as reference,
introspecd0_.tradingPartner as tradingP4_, introspecd0_.docType as
docType from Introspec_Document introspecd0_ inner join
Introspec_History statushist1_ on introspecd0_.id=statushist1_.docId
Hibernate: select introspecd0_.id as id0_, introspecd0_.name as name0_
from Introspec_DocType introspecd0_ where introspecd0_.id=?
ERROR   2004-06-10 12:14:29.561 [flow    ] (): I'm about to call
cocoon.sendPageAndWait()
ERROR   2004-06-10 12:14:29.632 [flow    ] (): I'm in postpipeline code
ERROR   2004-06-10 12:14:29.632 [flow    ] (): I'm inside catch(return)
Hibernate: select statushist0_.status as status__, statushist0_.date as
date__, statushist0_.docId as docId__ from Introspec_History
statushist0_ where statushist0_.docId=? order by statushist0_.date desc
Hibernate: select introspecs0_.id as id0_, introspecs0_.code as code0_
from Introspec_Status introspecs0_ where introspecs0_.id=?
Hibernate: select statushist0_.status as status__, statushist0_.date as
date__, statushist0_.docId as docId__ from Introspec_History
statushist0_ where statushist0_.docId=? order by statushist0_.date desc
Hibernate: select statushist0_.status as status__, statushist0_.date as
date__, statushist0_.docId as docId__ from Introspec_History
statushist0_ where statushist0_.docId=? order by statushist0_.date desc
Hibernate: select statushist0_.status as status__, statushist0_.date as
date__, statushist0_.docId as docId__ from Introspec_History
statushist0_ where statushist0_.docId=? order by statushist0_.date desc
Hibernate: select statushist0_.status as status__, statushist0_.date as
date__, statushist0_.docId as docId__ from Introspec_History
statushist0_ where statushist0_.docId=? order by statushist0_.date desc
Hibernate: select statushist0_.status as status__, statushist0_.date as
date__, statushist0_.docId as docId__ from Introspec_History
statushist0_ where statushist0_.docId=? order by statushist0_.date desc
Hibernate: select statushist0_.status as status__, statushist0_.date as
date__, statushist0_.docId as docId__ from Introspec_History
statushist0_ where statushist0_.docId=? order by statushist0_.date desc
Hibernate: select statushist0_.status as status__, statushist0_.date as
date__, statushist0_.docId as docId__ from Introspec_History
statushist0_ where statushist0_.docId=? order by statushist0_.date desc
Hibernate: select statushist0_.status as status__, statushist0_.date as
date__, statushist0_.docId as docId__ from Introspec_History
statushist0_ where statushist0_.docId=? order by statushist0_.date desc

You can clearly see the hibernate request being executed after passing
through both postpipeline and catch(return) blocks.

Looking back at
http://wiki.cocoondev.org/Wiki.jsp?page=RhinoWithContinuations, it seems
obvious that catch(return) is only used with continuation objects so
it's ignored when calling sendPage().

But I think this is quite ambiguous:

>If you want to execute Flowscript code after calling the view layer but
before control
>leaves the interpreter, catch(return) will help

If "after calling the view layer" means "just after calling the view
layer, but before it's completed", I can't see any use for this feature.

So far, it looks like there's no way to know when the view pipeline is
completed, maybe this is to avoid problems if the view "re-entered" the
flow (just guessing) ?

Finally, I'd like to know if anyone can confirm what I'm reporting (I'm
running in a minimal cocoon environment and it's not impossible that I
removed some needed components...) ?

Thanks,

Nicolas.


-----Original Message-----
From: Leszek Gawron [mailto:lgawron@mobilebox.pl] 
Sent: 10 juin, 2004 05:37
To: users@cocoon.apache.org
Subject: Re: Flow + Hibernate and lazy initialization


Leszek Gawron wrote:
>> Well, I cannot see why the releasing cannot be done in the Javascript
>> statement following the sendPage... assuming the behaviour you 
>> observed was not just a bug in the Flowscript component, of course.
> 
> If this is as you say you should raise this problem at cocoon-dev. I
> also wanted to loose Open Session In View pattern in favor of some 
> hibernate avalon component, but that looks impossible now.
See this[1], and this[2] and this[3] and this[4]

[1] http://marc.theaimsgroup.com/?t=108681937800001&r=1&w=2&n=2
[2] http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=105825181219265&w=2
[3] http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=105825410721036&w=2
[4] http://wiki.cocoondev.org/Wiki.jsp?page=RhinoWithContinuations
	LG


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


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


Re: Flow + Hibernate and lazy initialization

Posted by Leszek Gawron <lg...@mobilebox.pl>.
Leszek Gawron wrote:
>> Well, I cannot see why the releasing cannot be done in the Javascript 
>> statement following the sendPage... assuming the behaviour you 
>> observed was not just a bug in the Flowscript component, of course.
> 
> If this is as you say you should raise this problem at cocoon-dev. I 
> also wanted to loose Open Session In View pattern in favor of some 
> hibernate avalon component, but that looks impossible now.
See this[1], and this[2] and this[3] and this[4]

[1] http://marc.theaimsgroup.com/?t=108681937800001&r=1&w=2&n=2
[2] http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=105825181219265&w=2
[3] http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=105825410721036&w=2
[4] http://wiki.cocoondev.org/Wiki.jsp?page=RhinoWithContinuations
	LG


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


Re: Flow + Hibernate and lazy initialization

Posted by Leszek Gawron <lg...@mobilebox.pl>.
Nicolas Bielza wrote:
> I don't think it's a bug. sendPage() doesn't wait for the pipeline to
> complete.
> If I close my Hibernate connection right after the call to sendPage(),
> the lazy initialization fails (in the velocity generator step).
> I need to know when the pipeline processing is complete so I can safely
> close the session.
> 
> Regards,
> 
> Nicolas.
> 
> -----Original Message-----
> From: news [mailto:news@sea.gmane.org] On Behalf Of Luca Morandini
> Sent: 9 juin, 2004 17:01
> To: users@cocoon.apache.org
> Subject: Re: Flow + Hibernate and lazy initialization
> 
> 
> Nicolas Bielza wrote:
> 
>>According to the doc, the postpipeline code is useful to release 
>>resources that should not become part of the continuation, but are 
>>needed during pipeline processing. Although there's no script 
>>suspension with cocoon.sendPage(), it's not unlikely that some 
>>resources should be released after pipeline processing is complete 
>>(and it's exactly what I need to achieve).
> 
> 
> Well, I cannot see why the releasing cannot be done in the Javascript 
> statement following the sendPage... assuming the behaviour you observed 
> was not just a bug in the Flowscript component, of course.
If this is as you say you should raise this problem at cocoon-dev. I 
also wanted to loose Open Session In View pattern in favor of some 
hibernate avalon component, but that looks impossible now.
	LG

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


RE: Flow + Hibernate and lazy initialization

Posted by Nicolas Bielza <ni...@alligacom.com>.
I don't think it's a bug. sendPage() doesn't wait for the pipeline to
complete.
If I close my Hibernate connection right after the call to sendPage(),
the lazy initialization fails (in the velocity generator step).
I need to know when the pipeline processing is complete so I can safely
close the session.

Regards,

Nicolas.

-----Original Message-----
From: news [mailto:news@sea.gmane.org] On Behalf Of Luca Morandini
Sent: 9 juin, 2004 17:01
To: users@cocoon.apache.org
Subject: Re: Flow + Hibernate and lazy initialization


Nicolas Bielza wrote:
> 
> According to the doc, the postpipeline code is useful to release 
> resources that should not become part of the continuation, but are 
> needed during pipeline processing. Although there's no script 
> suspension with cocoon.sendPage(), it's not unlikely that some 
> resources should be released after pipeline processing is complete 
> (and it's exactly what I need to achieve).

Well, I cannot see why the releasing cannot be done in the Javascript 
statement following the sendPage... assuming the behaviour you observed 
was not just a bug in the Flowscript component, of course.

Regards,

---------------------------
      Luca Morandini
    lmorandini@ieee.org
http://www.lucamorandini.it
---------------------------


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


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


Re: Flow + Hibernate and lazy initialization

Posted by Luca Morandini <lu...@tin.it>.
Nicolas Bielza wrote:
> 
> According to the doc, the postpipeline code is useful to release
> resources that should not become part of the continuation, but are
> needed during pipeline processing. Although there's no script suspension
> with cocoon.sendPage(), it's not unlikely that some resources should be
> released after pipeline processing is complete (and it's exactly what I
> need to achieve).

Well, I cannot see why the releasing cannot be done in the Javascript 
statement following the sendPage... assuming the behaviour you observed 
was not just a bug in the Flowscript component, of course.

Regards,

---------------------------
      Luca Morandini
    lmorandini@ieee.org
http://www.lucamorandini.it
---------------------------


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


RE: Flow + Hibernate and lazy initialization

Posted by Nicolas Bielza <ni...@alligacom.com>.
Yes, I tried it just to make sure and it doesn't work :-(

According to the doc, the postpipeline code is useful to release
resources that should not become part of the continuation, but are
needed during pipeline processing. Although there's no script suspension
with cocoon.sendPage(), it's not unlikely that some resources should be
released after pipeline processing is complete (and it's exactly what I
need to achieve).

I wonder if sendPageAndWait, with timeToLive set to 0 does create a
continuation object ?

Nicolas.

-----Original Message-----
From: news [mailto:news@sea.gmane.org] On Behalf Of Luca Morandini
Sent: 9 juin, 2004 08:56
To: users@cocoon.apache.org
Subject: Re: Flow + Hibernate and lazy initialization


Leszek Gawron wrote:

> Have you tried this?:
> 
> function someView() {
>     var session = obtainSession();
>     var data = dao.getData( session );
>     cocoon.sendPage( "view/someView.jx",
              ^^^^^^^^
>                      { data: data },
>                      function() { session.close(); } );
> }

Did you mean "sendPageAndWait" instead ?
According to the doc, "sendPage" has no "postPipelineCode" argoment... 
neither it should have, IMO, since there is no script suspension.

Regards,

---------------------------
      Luca Morandini
    lmorandini@ieee.org
http://www.lucamorandini.it
---------------------------


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


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


Re: Flow + Hibernate and lazy initialization

Posted by Luca Morandini <lu...@tin.it>.
Leszek Gawron wrote:

> Have you tried this?:
> 
> function someView() {
>     var session = obtainSession();
>     var data = dao.getData( session );
>     cocoon.sendPage( "view/someView.jx",
              ^^^^^^^^
>                      { data: data },
>                      function() { session.close(); } );
> }

Did you mean "sendPageAndWait" instead ?
According to the doc, "sendPage" has no "postPipelineCode" argoment... 
neither it should have, IMO, since there is no script suspension.

Regards,

---------------------------
      Luca Morandini
    lmorandini@ieee.org
http://www.lucamorandini.it
---------------------------


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


Re: Flow + Hibernate and lazy initialization

Posted by Leszek Gawron <lg...@mobilebox.pl>.
Nicolas Bielza wrote:

> Hi,
> 
> I ran into a small problem when using hibernate inside a flowscript and
> a velocity template to generate the XML from the "hibernated" objects.
> Here's what I'm doing:
> 
> 1. Get a hibernate session and retrieve some objects from the DB.
> 2. Pass these objects to a velocity generator to create some XML (I'm
> calling cocoon.sendPage()).
> 3. Close the hibernate session.
> 
> Now, when I serialize the velocity output to XML, there's no problem; if
> I add a XSL transform step and serialize to HTML, I get lazy
> initialization exceptions. 
Have you tried this?:

function someView() {
     var session = obtainSession();
     var data = dao.getData( session );
     cocoon.sendPage( "view/someView.jx",
                      { data: data },
                      function() { session.close(); } );
}

see
http://cocoon.apache.org/2.1/userdocs/flow/api.html#Cocoon+Object

-- 
Leszek Gawron                                      lgawron@mobilebox.pl


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