cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Søren Krum <soren.k...@uninett.no>
Subject Re: Hibernate and Cocoon 2.2 - best practice
Date Mon, 26 Oct 2009 07:25:52 GMT
Hi!

We are using cocoon 2.2 and hibernate. I am not sure if we choosed the 
optimal way to integrate these both, but for us it works.

We configured all database connections via spring as DataSource, and 
these we use further on for the hibernate session factories and for the 
"old" avalon data sources as well. Neither the sql-transformer nor 
hibernate complained so long. But they get seperate data sources ;-), so 
why should they?

The access to hibernate managed java objects is done via the standard 
hibernate way: Getting a factory, getting a session, 
fetching/manipulating your object. We use a central class, a 
(scope=singleton) HibernateUtil, to get the connection to the different 
hibernate session factories. This Util class additionally offers some 
easy ways to fetch and delete objects without carying for all the 
session/transaction stuff. Handy if you need your hibernate objects in a 
flow script.

The cases with a bit more complex java objects we placed in own dao 
objects, which are accessed only via some service classes. Extra effort, 
yes, but very nice if it comes do transaction handling. AOP is worth a 
try here, and with spring and the descriptions they provide it works 
fine for us.

Regards

Søren


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


Mime
View raw message