Sunday, February 26, 2006

Hibernate vs ActiveRecord

Over the last 2+ years I've grown quite accustomed to the facilities of Hibernate (one of the most popular Java object-relational persistence frameworks). And before that I used TopLink for a couple of years. So now when it comes to my work with Ruby on Rails I have some pretty high expectations.

The out-of-box experience with Rails' persistence framework is undoubtedly different but similar enough to Hibernate to make life fairly comfortable. But recently I started watching the SQL that gets generated from Rails and decided I'd like to optimize them a bit. But unfortunately that isn't as easy as everything else in Rails. I found this article at TheServerSide that sums things up pretty well. I think Rails comes out on the losing end. Now the question becomes, are the things you lose worth the things you gain?

1 comment:

Anonymous said...

The author of this article wrote a book about Hibernate, so of courrse Hibernate comes out on top. The main argument he has for Hibernate being better is that you have to go to the database to know what the field names and types are.

This shows a woeful ignorance of Rails' ActiveRecord implementation and migrations.

Sorry, but I'll take Migrations and ActiveRecord over Hibernate's code generation for long-term code maintainability any day.