Hibernate and Cocoon 2.2 - best practice

View: New views
3 Messages — Rating Filter:   Alert me  

Hibernate and Cocoon 2.2 - best practice

by Kamal-6 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,
I was wondering if someone who uses Cocoon 2.2 and Hibernate could
provide some tips on using Hibernate and Cocoon 2.2 together?  For
example, how do others configure the connections, call in the DAO (eg
using Spring or calling them directly), etc...

An example would be nice.

Thanks.


--
Kamal Bhatt


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


Re: Hibernate and Cocoon 2.2 - best practice

by Søren Krum :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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@...
For additional commands, e-mail: users-help@...


Re: Hibernate and Cocoon 2.2 - best practice

by Luca Morandini-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 26/10/09 08:25, Søren Krum wrote:
>
> 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.

More or less same here, though I used a filter Servlet to take care of sessions
and bound them to the localthread of each servlet invocation, in order to avoid
the oops-the-session-expired-while-the-pipeline-was-being-processed issue.

I manipulatoed DAOs via Flowscript for added flexibility, which means every Java
domain class has its own DAO class for manipulation... hmm... not really, some
domain classes I managed to subclass.

What I miss is a more direct way from domain classes to the (AJAX) client and
back, without all the packing and unpacking of things (though I used JSON for
communications)... I suppose Restlet/Kauri may come in handy, but I did not feel
like plunging into it.

Regards,

--------------------
    Luca Morandini
www.lucamorandini.it
--------------------


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