TheServerSide.com – Hibernate vs. Rails: The Persistence Showdown

1

An interesting article comparing two OO/R frameworks: Hibernate and RAILS. It gives a good indication of what you should look for when investigating OO/R mapping/persistency frameworks. TheServerSide.com – Hibernate vs. Rails: The Persistence Showdown

You could apply this same kind of analysis to alternatives such as: Toplink, Ibatis, OJB, JDO, EJB 3.0, Oracle ADF Business Components etc.

By the way, the main conclusion is: Hibernate is more mature and has features required for large, scalable applications. On the other hand, RAILS is simple to learn and very quickly gets you going, especially on smaller endeavours.

Beyond the basics, Hibernate adds quite a few more mapping types (I documented a complete catalog of examples with over 20 mappings in Hibernate Quickly), including different inheritance strategies, custom user types, and maps of entity or simple types. While it’s simpler to specify and use simple associations in Rails than in is in Hibernate, but there is less you can do with them. If you stick to the simple cases like single tables with a few associations, and you name your tables and columns right, Rails will likely do just fine, but for more complicated object models, Hibernate will be a better choice.

Rails and Hibernate are very different when it comes to query languages. While its not possible to do an exhaustive comparison of their query languages, generally selects for single objects/tables will be quicker and easier for Rails, and anything join related is better suited for Hibernate. Rails use SQL, which is familiar to most developers, while Hibernate offers HQL a OO query language that developers will need to learn. In addition, Hibernate offers quite a few more tuning opportunities, providing the necessary ORM mechanisms, like outer join fetching, configurable lazy fetching and second level caching. This further supports the theory that Rails is likely suitable for smaller projects, but its ORM layer lacks a number of the essential features that will allow it to scale up to larger projects.

It reminds me that we should take a look at Ruby. Too much buzz to remain ignorant.

Share.

About Author

Lucas Jellema, active in IT (and with Oracle) since 1994. Oracle ACE Director for Fusion Middleware. Consultant, trainer and instructor on diverse areas including Oracle Database (SQL & PLSQL), Service Oriented Architecture, BPM, ADF, Java in various shapes and forms and many other things. Author of the Oracle Press book: Oracle SOA Suite 11g Handbook. Frequent presenter on conferences such as JavaOne, Oracle OpenWorld, ODTUG Kaleidoscope, Devoxx and OBUG. Presenter for Oracle University Celebrity specials.

1 Comment

  1. Mike Swierczek on

    Hibernate offers its Hibernate Query Language, but you can use SQL too. You may need to learn HQL if you’re working on an existing project that uses it, but if you’re writing your own Hibernate application from scratch, you can ignore HQL entirely.