Object Relational Mapping

Object relational mapping frameworks such as Hibernate and Java Persistence API’s are beyond their initial hype. The use of them is still surrounded by controversy on internet publications (for example see the post: The Vietnam of computer science) and equally so our office. Also for the people that do choose to use there is a wide range of do’s and don’ts that have emerged from using them.

In this article my view on the origin of OR Mappers. OR Mappers have been around for some time now. They have more or less suddenly gained wide spread use since in the last 4 years. I explain this surge of use by the evolution of database access vogue in the Java community:

JDBC is a low level database access API and is not a good abstraction layer. It is a very leaky abstraction making it hard to do proper database programming for Java. You are confronted with low level stuff like: parameter and result passing, session management and error handling.

As a response Sun and IBM came up with the EJB 2 standard. A container based approach where persistency to a database is part of the container services. Most people that tried EJB2 failed for a number of reasons. My take is that the EJB2 spec and implementation is over the top for over 95% of the software being written. Given that EJB2 is too big, a more lightweigth approach is needed. At that same point in history Hibernate is starting to emerge and it quickly gets momentum.

While Hibernate is a far better approach that EJB 2, for me the reference point for choosing a database access layer is JDBC. I think for most applications also Hibernate adds unnecessary and unwanted complexity. In those cases a simple abstraction layer on top of JDBC (like JDBCTemplate from Spring) or some homegrown set of API’s is enough.

Ironically enough also Hibernate can provide this abstraction layer. However most teams have a tendency to use Hibernate all the way and end up shooting themselves in the foot.

More later on the so called object relational mismatch.


One Response to “Object Relational Mapping”

  1. Object Relational Impedance Mismatch « Arnoud on Software Development Says:

    […] Arnoud on Software Development About Software Development and Online Media « Object Relational Mapping […]

Comments are closed.

%d bloggers like this: