cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Johannes Textor <>
Subject Re: Cocoon / Hibernate revisited
Date Wed, 30 May 2007 23:01:44 GMT
Hi Tricia,
>    What is the advantage of using a DAO?
I'm not sure if I am the right person to answer this question, but I'll 
give it a try. Quoting from Wikipedia at

"Data Access Objects are a Core J2EE 
Design Pattern and considered best practice. ... Data Access Objects can 
be used in Java 
<> to 
insulate an application from the underlying Java persistence technology 

Anyway, my own view on this is that DAO, as any design patterns, is not 
useful per se, but only in certain situations. In fact, when I wrote my 
first applications using Cocoon and Hibernate, I simply called Hibernate 
directly from the flowscript layer.

However, as my applications got more and more complex, this turned out 
to be really messy. Doing all the data access on the flow layer had - 
for me - one big disadvantage: I had to do it in JavaScript, while all 
the classes I used and Hibernate itself were written in Java. The 
obvious mismatch between the two leads to a lot of issues, from proper 
exception handling to having to use weird syntax for "delete" methods 
(hs["delete"](obj), for example, since delete is a reserved keyword in 
JS). Furthermore, I simply missed my Eclipse and a strongly-typed 
language like Java seemed better suited for complex operations on 
business data. In the end, all the (luckily, few) applications I started 
like this have now grown into an ugly, unmanageable mess.

Personally, I think that flowscript is one of the main (and honestly, 
few) advantages Cocoon still has over other web application frameworks, 
but this strength only shows if you use it *just what it was designed 
for*, i.e. *control of page flow*. All non-trivial operations on 
bussiness data should, IMHO, *not* be done in flowscript. This means 
that you have to do them somewhere else - and here, the DAO pattern 
comes in handy. Using it, I have finally been able to code some 
applications in Cocoon and Hibernate I can actually be proud of.

I hope this gives you an Idea of why I'm recommending to use DAOs, but 
still, I do not think that this must necessarily be the right approach 
for everybody, just because it is "considered best practice".


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message