Hi Manuel,
I have no real experience with Hibernate, but i'll try to help you out.
I guess you are refering to the HibernateTutorial [1] on the wiki?
Manuel Mata wrote:
Hi all. I need to make a query using Hibernate from an
Action. I see that in HibernateTutorial in the "hs.js"
file it does something like:
I should do something like that in my action and close
the session explicity because after the session comes
an flowscript function that opens a new one. I would
like to use the Cocoon management of connections so i
wonder if it is possible instead of open an hibernate
session explicity.
Looking at the tutorial page it seems that you can do that. If you look
at the HibernateFactory class file on the page they are doing exactly
that. As the wiki page states: "The crucial part is createSession(),
where we tell Hibernate to use a connection from the Cocoon pool. This
connection is selected using the avalon framework API."
To be more specific:
// Select the DataSourceComponent named "test"
// This is a normal SQL connection configured in cocoon.xconf
ServiceSelector dbselector = (ServiceSelector)
manager.lookup(DataSourceComponent.ROLE+"Selector");
datasource = (DataSourceComponent) dbselector.select("test");
//name as defined in cocoon.xconf
hs = sf.openSession(datasource.getConnection());
I read in flowscript documentation that "Cocoon object
represents the current Cocoon Sitemap", but i dont
know how to access that object in the action. I search
on API but found nothing, even looking
ObjectModelHelper. I looked Cocoon Database Actions
section but is a different approach (without
hibernate).
With the help of the cocoon object in the FOM you can call objects like
the request, response, session but also other Avalon components which
are available in Cocoon.
From with in an Action you should be able to directly call those Avalon
components without having to access the cocoon object. Looking at the
AbstractDatabaseAction and the DatabaseAddAction it seems they are doing
sort of the same as described on the Hibernate wiki page, except not
with hibernate indeed.
Can anyone help me ? Thx. Excuse my english.
I think you can use pieces of code from the Hibernate wiki page to
create your action.
Kind regards,
Jeroen Reijn
[1]http://wiki.apache.org/cocoon/CocoonAndHibernateTutorial
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]