You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Joe Baldwin <jf...@earthlink.net> on 2007/08/09 20:23:49 UTC

ORM Comparison

This is a general question I would guess at the "use case" level.

I was recently in a conversation in which I was challenged about the  
selection of Cayenne over Hibernate.  I have only researched  
Hibernate & run some elementary demo tests.  My conclusion was that  
Hibernate allows you to create a mapping via an XML metadata file but  
that some of the mapping responsibilities (currently found in  
Cayenne) are left to the programmer to resolve and maintain.  I  
specifically pointed to Cayenne Modeler as an example of an essential  
tool supporting the 'change it in one place' philosophy that impacts  
maintenance time budgeting.

It was asserted that Hibernate could do anything that Cayenne could  
do.  In addition, the CayenneModeler advantage was dismissed with a  
comment concerning an Eclipse plugin that is supposed to support the  
same features.

Things change very quickly in the OpenSource world so perhaps I could  
have made a mistake, however, I don't think that I am that far off  
the mark.  Is there a white paper that might discuss the differences  
(couldn't find one at the Hibernate site)?  Does anyone have an opinion?


Re: ORM Comparison

Posted by Joe Baldwin <jf...@earthlink.net>.
Thanks for your comment concerning the large data sets.  As I recall,  
EOF choked on large data sets when I was coding Obj-C.  I don't know  
what the problem was, but I do recall that there was a hard limit.

My interest (right now) is primarily with the various methods by  
which Entities & Relationships can be mapped using the two different  
tools and then how much capability is offered using the two different  
(or perhaps not so different) persistence-management models.  My  
*current* understanding is that Cayenne is very similar to EOF and  
relies upon the CayenneModeler to: create/analyze/reverse-engineer  
(or any combo) resulting in cayenne metadata (xml files),  
instantiated DBMS schema, and auto-generated Java persistence  
classes.  Whereas Hibernate relies on a raw (hand edited) xml- 
metadata file, but also supports the xdoclet POJO mapping (which  
*appears* to support/require that the objects be maintained by  
programmer)

Also, if I understand correctly, Cayenne may have a tad more elegant  
and mature persistence architecture (guessing on this one because I  
am not an EOF expert).

The advantage of EOF and EOF Modeler was the maturity of the  
architecture with respect to managing the DataContext-layer as well  
as it was a central hub for instantiation of an abstract Entity- 
Relationship model.  I have not been able to verify if Hibernate  
"groks" this way of being used or not.  Cayenne certainly does.







On Aug 9, 2007, at 2:23 PM, Joe Baldwin wrote:

> This is a general question I would guess at the "use case" level.
>
> I was recently in a conversation in which I was challenged about  
> the selection of Cayenne over Hibernate.  I have only researched  
> Hibernate & run some elementary demo tests.  My conclusion was that  
> Hibernate allows you to create a mapping via an XML metadata file  
> but that some of the mapping responsibilities (currently found in  
> Cayenne) are left to the programmer to resolve and maintain.  I  
> specifically pointed to Cayenne Modeler as an example of an  
> essential tool supporting the 'change it in one place' philosophy  
> that impacts maintenance time budgeting.
>
> It was asserted that Hibernate could do anything that Cayenne could  
> do.  In addition, the CayenneModeler advantage was dismissed with a  
> comment concerning an Eclipse plugin that is supposed to support  
> the same features.
>
> Things change very quickly in the OpenSource world so perhaps I  
> could have made a mistake, however, I don't think that I am that  
> far off the mark.  Is there a white paper that might discuss the  
> differences (couldn't find one at the Hibernate site)?  Does anyone  
> have an opinion?
>


Re: ORM Comparison

Posted by Malcolm Edgar <ma...@gmail.com>.
Having uses both Hibernate & Cayenne for many commercial project, I have
found Cayenne to be much more productive 2x.

With Hibernate you need to:
* setup a lot of configuration stuff, or use Spring to do this for you
* write your Java classes
* write your mapping files
* design your database
* generate your database

With Cayenne you:
* model your db entities & object entities and their relationships
* generate classes
* generate database

Hibernate also encourages a top down approach, which I think for most
business applications is wrong. If you get the database model wrong in your
application you are in real trouble.  This is where your initial design
focus should be, not at the object entities, which most applications simply
map to the db schema.

With Cayenne you also can refactor code much more quickly, and the
subclass/superclass generation pattern is really good as you don't clobber
your business methods when you regenerate data object superclasses. With
Hibernate you have to manually maintain the mapping file relationships to
the database tables and the Java classes.

In our web applications we through away the DataContext with each request,
so we don't have any memory issues. NamedQueries returning RowMap objects
are also very performant, especially when paged.

The Cayenne Modeler has a few wrinkles but once you get used to them,
Cayenne beats the pants of Hibernate. I have tried a few time to get the
JBoss Hibernate Eclipse plug-in going but never with any success.

regards Malcolm Edgar

On 8/10/07, Robert Zeigler <ro...@puregumption.com> wrote:
>
> Probably would... I was using 2.x for this particular project,
> in large part because it needed to be done very, very quickly
> (~1 month to replace an app that had been somewhere around 20k lines
> of php).
>
> Robert
>
> On Aug 9, 2007, at 8/94:23 PM , Joe Baldwin wrote:
>
> > Robert,
> >
> >> Hm...  I recently wrote an app that involved processing large
> >> numbers of rows
> >> (to the tune of about 250,000 currently, and sure to increase
> >> rapidly).
> >> Granted, I had to code a little more carefully... create "throw
> >> away" data contexts
> >> for some operations, etc. But the app runs quite nicely with cayenne.
> >> What performance issues did you encounter?
> >
> > Didn't I just recently read a post in which Andrus commented that
> > the original architecture assumed that persistence objects would
> > *not* be released until the DataContext is destroyed and garbage
> > collected.  I *believe* the new version allows more control over
> > the atomic release of data objects, if I recall.
> >
> > Could this have any influence on the performance issues that were
> > reported?
> >
> > Joe
> >
>
>

Re: ORM Comparison

Posted by Robert Zeigler <ro...@puregumption.com>.
Probably would... I was using 2.x for this particular project,
in large part because it needed to be done very, very quickly
(~1 month to replace an app that had been somewhere around 20k lines  
of php).

Robert

On Aug 9, 2007, at 8/94:23 PM , Joe Baldwin wrote:

> Robert,
>
>> Hm...  I recently wrote an app that involved processing large  
>> numbers of rows
>> (to the tune of about 250,000 currently, and sure to increase  
>> rapidly).
>> Granted, I had to code a little more carefully... create "throw  
>> away" data contexts
>> for some operations, etc. But the app runs quite nicely with cayenne.
>> What performance issues did you encounter?
>
> Didn't I just recently read a post in which Andrus commented that  
> the original architecture assumed that persistence objects would  
> *not* be released until the DataContext is destroyed and garbage  
> collected.  I *believe* the new version allows more control over  
> the atomic release of data objects, if I recall.
>
> Could this have any influence on the performance issues that were  
> reported?
>
> Joe
>


Re: ORM Comparison

Posted by Joe Baldwin <jf...@earthlink.net>.
Robert,

> Hm...  I recently wrote an app that involved processing large  
> numbers of rows
> (to the tune of about 250,000 currently, and sure to increase  
> rapidly).
> Granted, I had to code a little more carefully... create "throw  
> away" data contexts
> for some operations, etc. But the app runs quite nicely with cayenne.
> What performance issues did you encounter?

Didn't I just recently read a post in which Andrus commented that the  
original architecture assumed that persistence objects would *not* be  
released until the DataContext is destroyed and garbage collected.  I  
*believe* the new version allows more control over the atomic release  
of data objects, if I recall.

Could this have any influence on the performance issues that were  
reported?

Joe


Re: ORM Comparison

Posted by Robert Zeigler <ro...@puregumption.com>.
On Aug 9, 2007, at 8/93:18 PM , Tomi N/A wrote:

> 2007/8/9, Joe Baldwin <jf...@earthlink.net>:
>
>> Things change very quickly in the OpenSource world so perhaps I could
>> have made a mistake, however, I don't think that I am that far off
>> the mark.  Is there a white paper that might discuss the differences
>> (couldn't find one at the Hibernate site)?  Does anyone have an  
>> opinion?
>
> It's hard to compare the two seeing as most people use one or the  
> other.
> I use cayenne in my projects: I didn't know much about cayenne or
> hibernate when I chose (2-3 years back).
> At the moment, I'm considering using hibernate in (at least) some of
> my applications because I've run into scalability issues I couldn't
> find a satisfactory solution for: I need to process tens of thousands
> of objects in memory so that I can generate reports. I got less than
> satisfactory results with cayenne, but I see hibernate has at least
> some (declarative support for large datasets:


Hm...  I recently wrote an app that involved processing large numbers  
of rows
(to the tune of about 250,000 currently, and sure to increase rapidly).
Granted, I had to code a little more carefully... create "throw away"  
data contexts
for some operations, etc. But the app runs quite nicely with cayenne.
What performance issues did you encounter?


> http://www.hibernate.org/hib_docs/reference/en/html/batch.html
> http://www.hibernate.org/hib_docs/entitymanager/reference/en/html/ 
> batch.html
> Also, the modeler provides rather limited functionality when updating
> (rather than regenerating) a mapping which is a fairly common
> operation in my environment.

Hm, I'm going to assume that you're referring to updating an existing  
database schema that already has data in it?
I'm curious if hibernate has some solution to this problem?

> Don't get me wrong: if I wanted to list cayennes strong points, the
> list would be very long, starting or finishing with probably the best
> spirited community I've had the pleasure to be a part of. It's just
> that in my case I ran into issues hibernate seems to address
> explicitly, like the huge datasets I mentioned. Don't know if I'll run
> into a wall with hibernate, as well. Maybe I'll miss ROP or
> something...
>
> Anyway, enough from me.
> Cheers and thumbs up to the people making cayenne what it is!
> t.n.a.


Re: ORM Comparison

Posted by Tomi N/A <he...@gmail.com>.
2007/8/9, Joe Baldwin <jf...@earthlink.net>:

> Things change very quickly in the OpenSource world so perhaps I could
> have made a mistake, however, I don't think that I am that far off
> the mark.  Is there a white paper that might discuss the differences
> (couldn't find one at the Hibernate site)?  Does anyone have an opinion?

It's hard to compare the two seeing as most people use one or the other.
I use cayenne in my projects: I didn't know much about cayenne or
hibernate when I chose (2-3 years back).
At the moment, I'm considering using hibernate in (at least) some of
my applications because I've run into scalability issues I couldn't
find a satisfactory solution for: I need to process tens of thousands
of objects in memory so that I can generate reports. I got less than
satisfactory results with cayenne, but I see hibernate has at least
some (declarative support for large datasets:
http://www.hibernate.org/hib_docs/reference/en/html/batch.html
http://www.hibernate.org/hib_docs/entitymanager/reference/en/html/batch.html
Also, the modeler provides rather limited functionality when updating
(rather than regenerating) a mapping which is a fairly common
operation in my environment.
Don't get me wrong: if I wanted to list cayennes strong points, the
list would be very long, starting or finishing with probably the best
spirited community I've had the pleasure to be a part of. It's just
that in my case I ran into issues hibernate seems to address
explicitly, like the huge datasets I mentioned. Don't know if I'll run
into a wall with hibernate, as well. Maybe I'll miss ROP or
something...

Anyway, enough from me.
Cheers and thumbs up to the people making cayenne what it is!
t.n.a.

Re: ORM Comparison

Posted by Joe Baldwin <jf...@earthlink.net>.
Robert,

These are the *kind* of comments I am looking for; thanks for the  
details, I have a few followup questions.

I also found that Cayenne is a cogent framework that results in  
higher productivity because not only is it feature rich, but the work- 
flow aspect is considered essential to the design (and not just an  
afterthought). BTW, I also experienced the "quick-start" phenomenon  
with Cayenne; it was a welcome surprise.

So after re-reading your comments, I suspect one of the more  
important aspects is work-flow.  In your experience, is it possible  
to configure a number of 3rd party software to create the Cayenne- 
like work-flow that is facilitated by CayenneModeler?

So unless one is a cowboy-programmer (ref Agile-insult :) ), then  
evolving a database in a methodical manner would seem to be better  
managed via the CayenneModeler and the Cayenne way of "groking"?

Joe







On Aug 9, 2007, at 4:28 PM, Robert Zeigler wrote:

> In terms of raw mapping capabilities ("what can be mapped, and  
> how"), hibernate basically has cayenne beat at this point.
> For example, hibernate supports things lie mapping to-many  
> relationships as lists, arrays, or maps ( cayenne currently only  
> supports mapping them as lists).
> Cayenne may have some mapping facilities not in hibernate, but none  
> that I'm aware of offhand (maybe the extended types facility? Not  
> sure if hibernate has an equivalent to that,
> but they probably do; oh, when I first starting using cayenne,  
> cayenne supported "lazy" relationship fetching and hibernate did  
> not, but hibernate now supports it).
>
> As you mentioned, cayenne has the modeler, whereas hibernate does  
> not offer any such support (except through 3rd parties).  ANd that,  
> in my mind, is the biggest difference. Not the modeler,
> but the mindset.  Hibernate is about "let's make an ORM with lots  
> of features".  Cayenne is about "let's make a tool and library that  
> makes developers productive".
>
> When I first delved into the world of ORM, I spent three days  
> trying to grok hibernate.  Finally, recalling that some other users  
> of tapestry were using cayenne, I tried it.
> Two hours later, my objects were mapped and created, my schema was  
> created, and I was writing my objects.  I've never looked back. I  
> wish I could say that dichotomy has lessened;
> that the hibernate people had realized "hey, people might actually  
> want to /use/ our project, instead of admire our technical genius  
> from a distance", but it doesn't appear that that's the case.
> On their website, they have a "roadmap to getting started quickly  
> with hibernate". Here's their roadmap:
>
> "Day 1: Work with the tutorials
>
>     * Download Hibernate 3.2 and extract the archive.
>
>     * Reference documentation: Read the tutorial, work with the  
> source code in the /doc/tutorial/ directory of the Hibernate  
> package. This tutorial covers a simple Hibernate standalone and web  
> application.
>
>     * Java Persistence with Hibernate: Read the tutorial in the  
> free sample chapter 2 of the book, download the Hello World code.  
> This tutorial is a complete introduction to Hibernate, Java  
> Persistence, and EJB 3.0.
>
> Day 2: Read the Documentation
>
>     * Read the rest of the reference documentation.
>
>     * Consider reading the rest of the book Java Persistence with  
> Hibernate.
>
>     * Read the FAQ.
>
> Day 3: Start Coding!
>
>     * Many examples you find on the Net are still Hibernate 1.x or  
> 2.x - read the migration guide for a list of differences to  
> Hibernate3.
>
>     * Many good patterns can be found on the Wiki Community Area,  
> such as Sessions and transactions, Open Session in View, Generic  
> Data Access Objects, ...
>
>     * Once you are familiar with basic Hibernate, download the  
> CaveatEmptor example application."
> (from: http://www.hibernate.org/152.html)
>
> That's their "getting started quickly"... any questions? ;)
> (I could also point out things like: why is the web page named  
> 152.html? Is that: 152 hours of frustration before starting  
> hibernate? Is that 152 days of reading before you start? 152 things  
> you have to do before you understand hibernate? Granted, the name  
> of a web page has nothing to do with the technical quality of the  
> hibernate code.  The technical quality of the hibernate code is,  
> I'm sure, very good.  But it harks back to my original point of the  
> paradigm of the two projects. 152.html is not a name that you could  
> guess as a user. Similarly, the hibernate "way" is nothing  
> something you can guess your way through and be pleasantly rewarded  
> when something that you tried thinking "I wonder if this will work"  
> actually does.
> Now compare that to cayenne's quick start for cayenne version 2.0.
> http://cayenne.apache.org/doc20/quick-start.html
> Hey, look, I know what that url is telling me... and I generally  
> know what the cayenne API is telling me and asking me, even before  
> reading the javadocs...
> without reading other tutorials...
>
> For me, that's one of the key differences, and one of the main  
> things that keeps in using cayenne.  Keep in mind, this is all user  
> perspective. I'm sure there are people out there who find hibernate  
> easy to use... erm, maybe?
>
> Robert
>
> PS: cayenne also has ROP, which hibernate doesn't, so if you  
> interested in writing swing front ends (truly "rich" client apps,  
> instead of lame webapps... oops, did I say that? ;), cayenne is a  
> no-brainer...
>
> PPS:
>
> On Aug 9, 2007, at 8/91:23 PM , Joe Baldwin wrote:
>
>> This is a general question I would guess at the "use case" level.
>>
>> I was recently in a conversation in which I was challenged about  
>> the selection of Cayenne over Hibernate.  I have only researched  
>> Hibernate & run some elementary demo tests.  My conclusion was  
>> that Hibernate allows you to create a mapping via an XML metadata  
>> file but that some of the mapping responsibilities (currently  
>> found in Cayenne) are left to the programmer to resolve and  
>> maintain.  I specifically pointed to Cayenne Modeler as an example  
>> of an essential tool supporting the 'change it in one place'  
>> philosophy that impacts maintenance time budgeting.
>>
>> It was asserted that Hibernate could do anything that Cayenne  
>> could do.  In addition, the CayenneModeler advantage was dismissed  
>> with a comment concerning an Eclipse plugin that is supposed to  
>> support the same features.
>>
>> Things change very quickly in the OpenSource world so perhaps I  
>> could have made a mistake, however, I don't think that I am that  
>> far off the mark.  Is there a white paper that might discuss the  
>> differences (couldn't find one at the Hibernate site)?  Does  
>> anyone have an opinion?
>>
>


Re: ORM Comparison

Posted by Robert Zeigler <ro...@puregumption.com>.
In terms of raw mapping capabilities ("what can be mapped, and how"),  
hibernate basically has cayenne beat at this point.
For example, hibernate supports things lie mapping to-many  
relationships as lists, arrays, or maps ( cayenne currently only  
supports mapping them as lists).
Cayenne may have some mapping facilities not in hibernate, but none  
that I'm aware of offhand (maybe the extended types facility? Not  
sure if hibernate has an equivalent to that,
but they probably do; oh, when I first starting using cayenne,  
cayenne supported "lazy" relationship fetching and hibernate did not,  
but hibernate now supports it).

As you mentioned, cayenne has the modeler, whereas hibernate does not  
offer any such support (except through 3rd parties).  ANd that, in my  
mind, is the biggest difference. Not the modeler,
but the mindset.  Hibernate is about "let's make an ORM with lots of  
features".  Cayenne is about "let's make a tool and library that  
makes developers productive".

When I first delved into the world of ORM, I spent three days trying  
to grok hibernate.  Finally, recalling that some other users of  
tapestry were using cayenne, I tried it.
Two hours later, my objects were mapped and created, my schema was  
created, and I was writing my objects.  I've never looked back. I  
wish I could say that dichotomy has lessened;
that the hibernate people had realized "hey, people might actually  
want to /use/ our project, instead of admire our technical genius  
from a distance", but it doesn't appear that that's the case.
On their website, they have a "roadmap to getting started quickly  
with hibernate". Here's their roadmap:

"Day 1: Work with the tutorials

     * Download Hibernate 3.2 and extract the archive.

     * Reference documentation: Read the tutorial, work with the  
source code in the /doc/tutorial/ directory of the Hibernate package.  
This tutorial covers a simple Hibernate standalone and web application.

     * Java Persistence with Hibernate: Read the tutorial in the free  
sample chapter 2 of the book, download the Hello World code. This  
tutorial is a complete introduction to Hibernate, Java Persistence,  
and EJB 3.0.

Day 2: Read the Documentation

     * Read the rest of the reference documentation.

     * Consider reading the rest of the book Java Persistence with  
Hibernate.

     * Read the FAQ.

Day 3: Start Coding!

     * Many examples you find on the Net are still Hibernate 1.x or  
2.x - read the migration guide for a list of differences to Hibernate3.

     * Many good patterns can be found on the Wiki Community Area,  
such as Sessions and transactions, Open Session in View, Generic Data  
Access Objects, ...

     * Once you are familiar with basic Hibernate, download the  
CaveatEmptor example application."
(from: http://www.hibernate.org/152.html)

That's their "getting started quickly"... any questions? ;)
(I could also point out things like: why is the web page named  
152.html? Is that: 152 hours of frustration before starting  
hibernate? Is that 152 days of reading before you start? 152 things  
you have to do before you understand hibernate? Granted, the name of  
a web page has nothing to do with the technical quality of the  
hibernate code.  The technical quality of the hibernate code is, I'm  
sure, very good.  But it harks back to my original point of the  
paradigm of the two projects. 152.html is not a name that you could  
guess as a user. Similarly, the hibernate "way" is nothing something  
you can guess your way through and be pleasantly rewarded when  
something that you tried thinking "I wonder if this will work"  
actually does.
Now compare that to cayenne's quick start for cayenne version 2.0.
http://cayenne.apache.org/doc20/quick-start.html
Hey, look, I know what that url is telling me... and I generally know  
what the cayenne API is telling me and asking me, even before reading  
the javadocs...
without reading other tutorials...

For me, that's one of the key differences, and one of the main things  
that keeps in using cayenne.  Keep in mind, this is all user  
perspective. I'm sure there are people out there who find hibernate  
easy to use... erm, maybe?

Robert

PS: cayenne also has ROP, which hibernate doesn't, so if you  
interested in writing swing front ends (truly "rich" client apps,  
instead of lame webapps... oops, did I say that? ;), cayenne is a no- 
brainer...

PPS:

On Aug 9, 2007, at 8/91:23 PM , Joe Baldwin wrote:

> This is a general question I would guess at the "use case" level.
>
> I was recently in a conversation in which I was challenged about  
> the selection of Cayenne over Hibernate.  I have only researched  
> Hibernate & run some elementary demo tests.  My conclusion was that  
> Hibernate allows you to create a mapping via an XML metadata file  
> but that some of the mapping responsibilities (currently found in  
> Cayenne) are left to the programmer to resolve and maintain.  I  
> specifically pointed to Cayenne Modeler as an example of an  
> essential tool supporting the 'change it in one place' philosophy  
> that impacts maintenance time budgeting.
>
> It was asserted that Hibernate could do anything that Cayenne could  
> do.  In addition, the CayenneModeler advantage was dismissed with a  
> comment concerning an Eclipse plugin that is supposed to support  
> the same features.
>
> Things change very quickly in the OpenSource world so perhaps I  
> could have made a mistake, however, I don't think that I am that  
> far off the mark.  Is there a white paper that might discuss the  
> differences (couldn't find one at the Hibernate site)?  Does anyone  
> have an opinion?
>