cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Borut BolĨina <>
Subject Re: Cayenne vs Hibernate Comparison
Date Mon, 06 Sep 2010 18:47:29 GMT
Hello Joe,

I just recently began two projects based on Hibernate (and Tapestry 5), so I
have limited knowledge to compare, but some of the differences immediately
showed up:

1.Code Life cycle
If you have the luxury to start a project with no database schema, then in
Hibernate you can start with POJOs, annotate them, create database on the
fly (just by configuration) and make changes in code only. Another approach
is to create an ER model (in MySQL Workbench for example), forward
engineer/synchronize with the database and later create JAVA code with the
Hibernate tools in Eclipse. But the tool is limited, you have to correct
some output by hand. If you make lots of changes in the auto generated class
and if you make changes in your favorite ER modelling tool and make changes
to the database with this tool, then you have to re-generate java code at
least a few times and than means you have to re-generate this code to some
other package (I use com.acme.entities.generated) and make local merge of
the old POJOs with the new ones. It doesn't consume much time, but with
Cayenne you have auto-generated classes and subclasses where you put your
business logic. I like the Cayenne approach, but I never got used to Cayenne
modeler, since ot does not offer a graphical way of drawing or displaying db
artifacts (ER model). If one prefers to start a fresh db design with his/her
favorite ER modeling tool, then with Cayenne you reverse engineer the db
schema with the modeler (the db engine must support constraints for
relationships to appear in the modeler). When rev-engineered and not
satisfied with the names of the relationship names (as was the case before
smart naming strategy) you had to correct each one in the modeler and then
(re)create the java classes. But since only the "auto" classes are
(over)written no harm is done, except for the compiler errors which
immediately show the location of offending method names. If one wants to
have ER model, Cayenne model and the code itself in sync there is a lot of
discipline to commit to. I think this is easier with Hibernate POJOs/Eclipse
Hibernate Tools/ER modeler, at least you don't have to deal with two GUI
tools. I would love to hear how other manage the life cycle - code/model
modifications. I do not have much experience starting with an existing
database - I guess I am the lucky one :-)

2.ObjectContext versus Session
This one was a really bad surprise when started with Hibernate. Object life
cycle is much more natural with Cayenne. My first Lazyloading Exception
emotion was: "What the hell am I doing wrong?". Then I realized that I can
not follow the relationships if not eagerly fetched. _______ (insert some
ugly word). A big plus for Cayenne here. I was told that Seam framework has
solved the LazyLoadingException. Is this correct?

3.POJO versus DataObject
I haven't found a downside with my persistent objects inheriting from
DataObjects. POJO hype?

4.Bidirectional relationships
Associations in Hibernate are not inherently bidirectional as are in
Cayenne. According to Hibernate book this is considered a good thing. Quote:
"POJO oriented persistence engines such as Hibernate don't implement managed
associations. Contrary to EJB 2.0 CMR, Hibernate and JPA associations are
all inherently unidirectional. As far as Hibernate is concerned, the
association from Bid to Item is a different association then the association
from Item to Bid! This is a good thing - otherwise your entity classes
wouldn't be usable outside of a run time container.". I don't think this is
a valid reason - you can use Cayenne in whatever environment you want and it
manages the bidirectional relationships for you.

Hibernate wins here totaly. Not only it gives confort to developers and
managers, the book "Java persistence with Hibernate" really teaches you
techniques and good practices. Also gives some recipes and anti-patterns.
Cayenne will stay marginal if no book goes to print.

6.Integration to other frameworks
Hibernate wins here also. There are a number of frameworks which integrate
with Hibernate, just google "hibernate integration". Where is my long
awaited T5.2-Cayenne bridge? :-)

These are just first observations I encountered during first two months of
using Hibernate.


2010/9/5 Joe Baldwin <>

> Hi,
> I am again responsible for making a cogent Cayenne vs Hibernate Comparison.
>  Before I "reinvent the wheel" so-to speak with a new evaluation, I would
> like to find out if anyone has done a recent and fair comparison/evaluation
> (and has published it).
> When I initially performed my evaluation of the two, it seemed like a very
> easy decision.  While Hibernate had been widely adopted (and was on a number
> of job listings), it seemed like the core decision was made mostly because
> "everyone else was using it" (which I thought was a bit thin).
> I base my decision on the fact that Cayenne (at the time) supported enough
> of the core ORM features that I needed, in addition to being very similar
> conceptually to NeXT EOF (which was the first stable Enterprise-ready ORM
> implementations).  Cayenne seems to support a more "agile" development
> model, while being as (or more) mature than EOF.  (In my opinion. :) )
> It seem like there is an explosion of standards, which appear to be driven
> by "camps" of opinions on the best practices for accomplishing abstraction
> of persistence supporting both native apps and highly distributed SOA's.
> My vote is obviously for Cayenne, but I would definitely like to update my
> understanding of the comparison.
> Thanks,
> Joe

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message