cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jakub Kaniewski <j...@egonet.pl>
Subject Re: Using Hibernate via Java, not Flow
Date Thu, 14 Apr 2005 19:37:13 GMT
JD Daniels wrote:

> I didn't see the need for a cocoon component. I looked again, but 
> still can't find the article that got me going... basically here is my 
> setup:

I use cocoon component put method, that gets JDBC connection from cocoon 
pool.

My flow looks like described in article :

function openSession()
{
        var factory = 
cocoon.getComponent(Packages.bmnet.p3.cocoon.HibernateFactory.ROLE);
        var hs = factory.createSession();
        if (hs == null) { throw new 
Packages.org.apache.cocoon.ProcessingException("Hibernate session is 
null ");        }
        cocoon.releaseComponent(factory);   
        cocoon.session.setAttribute("DisposeHibernateSession",hs);
    return hs;
}

function closeSession(hs)
{
    hs.flush();
    hs.connection().close();
    hs.close();
}


And typical function called by sitemap looks like this :

function show(id)
{
var hs = openSession();
var k = new Packages.bmnet.p3.beans.WiadomoscKandydata();
hs.load(k, new java.lang.Integer(id));
cocoon.sendPage("jx/wiadomosci", {"wiadomosci": k});
}

And the servlet filter guarantee me that the session will be closed when 
I call cocoon.sendPage().

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


Mime
View raw message