I haven't used Hibernate 3.0, only the previous versions, but here's my
take:
1) Cayenne - Better exception handling. Hibernate's framework is awful,
exposing SQLExceptions and the like, you need Spring just to hide all
its checked exceptions (or write catches all day long). The messages
weren't any good anyway. Cayenne OTOH will say "field to large for
database column", not give some cryptic message that it couldn't store a
record.
2) Cayenne - Working criteria API. This is critical in my mind
especially for a rich domain model (criteria api is espoused by Eric
Evans/Martin Fowler). Hibernate's (last time I used it) had support that
wasn't usable (couldn't do a count, or paged query with it. I think it's
"kind of" supported now, not sure). It had a less Java friendly API
anyway for paging, Cayenne will give you a normal java.util.List that
could fault in objects as you access the list (the count is simply the
list size), without using a special API.
3) Cayenne - Cayenne Base Object. Your objects know their object id's,
whether they are persisted. I can serialize the object id's and get the
objects back without knowing what their key is. It makes the object
model richer and more straightforward in my opinion. POJOs are
overrated, it's not like they save you code, it seems all Hibernate
projects end up with some sort of BaseEntity object (that at least
defines an ID for all objects), and implements a Hibernate interface to
do onLoad, onSave stuff (Hibernate folks are in denial about POJOs). Oh
yeah, and Cayenne generates the property name strings for you as
constants so you can use them in your quieries, a simple bug eliminator.
Oh yeah, I don't miss seeing the "Lazy Initialization" error in
Hibernate.
4) The Cayenne way is a bit different, it only stores object types, not
primitives _directly_. You have to write your accessors to convert
from/to primitives. This fits with what I like anyway (see Streamlined
Object Modeling). I make the Cayenne superclass with protected accessors
by default (so only a rich domain model is exposed). So, in short, its
different, but not necessarily worse. Most types seem supported (such as
BigDecimal), but DateTime is lacking clean support.
5) The Cayenne modeler. In my mind this can go either way. The GUI is
"neat", and can save you some simple mistakes by having it validate, but
on the other hand, I wouldn't mind having other off-the-shelf ways to
muck with the XML (maybe XDoclet, annotations, or other). Out of these
items, this hasn't been a big factor for me.
Joel
-----Original Message-----
From: Mike Kienenberger [mailto:mkienen..laska.net]
Sent: Tuesday, June 21, 2005 10:19 AM
To: cayenne-use..bjectstyle.org
Subject: Cayenne vs Hibernate
I'm interested in hearing a comparison of Cayenne and Hibernate by any
former
or current Hibernate users.
What strengths does Cayenne have over Hibernate?
If possible, give your level of experience with Hibernate (Hibernate
versions used, months of use, or whatever metric you think is
reasonable).
Thanks!
-Mike
This archive was generated by hypermail 2.0.0 : Tue Jun 21 2005 - 12:27:36 EDT