Re: Hibernate and ActiveRecord (Ruby-on-Rails) comparison

[prev] [thread] [next] [Date index for 2005/04/05]

From: Perrin Harkins
Subject: Re: Hibernate and ActiveRecord (Ruby-on-Rails) comparison
Date: 03:29 on 05 Apr 2005
Tony Bowden wrote:
> 2) ORMs should auto-save changes without having to manually save()
> 
> I've seen this argument quite a few times, and I've never quite bought
> it. I suspect this is more true for people who want a way to work with
> objects that persist without ever really thinking they're dealing with a
> database. CDBI (and I presume AR) is more for people who "think" in
> database terms, and want rid of much of the drudgery. Before I had CDBI
> I'd still have to issue lots of UPDATE statements. CDBI just simplifies
> that.

I do think that having to keep track of which objects need update() 
called on them is a pain and a source of bugs.  I don't think it's 
trivial to do it automatically though, so I'm not sure CDBI should try.

> 3) AR makes you write SQL for complex queries, whereas Hibernate has
> its own Query Language
> 
> I think people know my views on this. SQL is good, not bad.

I agree, but his main point in this seemed to be that letting the OR 
tool, which already knows about your object relationships, write all the 
joins and stuff for you can be helpful when your schema gets beyond the 
toy demo level that the Rails articles usually show.

> 4) AR's lazy loading is a Bad Thing.
> 
> This is based on the statement that "one of the best way to improve
> performance is to limit the number of trips to the database.  Better 1
> big query than a few small ones."
> 
> This gets trotted out a lot. But it's a massive oversimplification. I've
> seen many cases where it's much better for performance to break a big
> query into thousands of of small ones.

There are always counterexamples, but Hibernate gives people many 
options and makes smart default choices, while CDBI forces everyone to 
write it by hand if they want to use one big query in place of many 
small ones.  Taking a look at some of the controls it provides for 
lazy-loading tuning might be worthwhile.  It has some pretty slick stuff 
for reducing trips to the database.

> Rails has interested me for quite a while, but the bit I like least
> about it is that all the components are part of the same suite and
> developed together.

I think ActiveRecord is actually separate, and I'm not sure if the other 
stuff was developed for Rails originally or not.

- Perrin

Re: Hibernate and ActiveRecord (Ruby-on-Rails) comparison
Perrin Harkins 03:29 on 05 Apr 2005

Generated at 09:29 on 27 Apr 2005 by mariachi v0.52