- Posted by: Tom Baeyens
- Posted on: April 29 2003 09:20 EDT
In my project (http://jbpm.org) I use entity-ejb's for persistence (cmp, cmr, ejb2.0). Now I'm considering to make the move to an O/R mapping tool like e.g. hibernate.
EJB is intended as a standard for making persistency layers portable. As strange as it may seem, I experience the opposite effect.
Let me explain : In my project, I need a few queries that are outside the scope of EJB-QL. This implies that I need to use the app-server specific deployment descriptor. If I want to run my enterprise application on another server, I need to find the corresponding mechanisms in that app-server and if they exists, rewrite the deployment descriptor accordingly. If I would use hibernate (or another O/R mapper that gives me the same functionality) those app-server dependancies would be eliminated.
The gained app-server independance is for me of greater value then the knowledge that I'm using a standard.
The query constructs that I need in my project and that are not supported by EJB-QL are :
* order by
* dynamically generated queries
In another thread on TSS Gavin King (developer Hibernate) names a few other wuery-constructs that are supported by Habernate but not by JDO. As far as I know, they are also not supported by EJB-QL :
* outer joins
* grouping, counting, aggregating
* returning multiple objects, or property values, or aggregates,
in a single row of results
What's your idea ? Do you thing there are good reasons to stick with cmp-ejb's ?
- Hibernate vs MVCSoft by Aaron Robinson on April 30 2003 04:52 EDT
I'd be interested to see a comparison between these.
Does Hibernate have a cache? MVCSoft presents you with a CMP like interface, does Hibernate have a CMP interface?
I don't know if this is what you're looking for but Anthony Berglas has made a fine comparison between O/R mapper tools (although he might be biased) : http://www.uq.net.au/~zzabergl/simpleorm/ORMTools.html
Hibernate has a cache but I don't know any details of it.
What do you mean by cmp-interface ?
I believe you define the OR mapping in MVCSoft in a similar way that you do with CMP, under the covers it converts it all into BMP. so you get the declarative power of CMP but are not tied down by the limited CMP support for things like dynamic queries, aggregates, read-only beans etc
JDOQL does allow the results of one query execution to be the candidate set over which a subsequent query executes - would this satisfy the "Subqueries" capability which Tom/Gavin identifies as missing in JDOQL?
JDOQL does not yet support aggregates. I have submitted a proposal for aggregation support in JDOQL which will be considered, perhaps amongst other aggregation proposals, for inclusion in JDO 2.0. My proposal does support "counting" and "returning multiple objects, or property values, or aggregates, in a single row of results", although it is unlikely that "grouping" would be attempted.
I think you're right about JDOQL not supporting "outer-joins", but if you can give me a simple outer-join scenario/example I'll see if I can describe it in JDOQL. I'll also see if its something that we should consider for JDO 2.0.
My apologies Robin, I didn't meant to compare JDO versus Hibernate. In my point of view (which has limited knowledge of O/R-mapper tools) JDO and Hibernate are in the same category of excellent O/R-mapper technologies. The comparison I tried to make was between O/R-mappers and EJB's persistency. I only wanted to point out that EJB-has some short-comings. The reason why I mentioned JDO is because I didn't want to quote Gavin out of context.
To reassure you, I think JDO has the advantage of being a standard. But non-standard-Hibernate seems to me as a more solid implementation then the best open source JDO implementation I'm aware of (Apache's OJB). If you think OJB is a better implementation to work with then Hibernate, I'm all ears for your arguments.
Respectfull regards, Tom.