Friday, June 04, 2004

Object Relational Mapping: Hibernate

In January, I posted a note about why I liked the Hibernate open source object/relational mapping tool. The EJB expert group liked it as well.

Politically Charged EJB Decision Hands a Victory to JBoss

The EJB expert group's decision to use Hibernate as the persistence mechanism in EJB 3.0 gives JBoss all the power. David Jordan, a member of the JDO expert group, explains why the JDO community is not just disappointedóbut concernedóabout a power shift in the app server market.

The EJB 3.0 expert group seems to have handed JBoss the EJB application server market on a silver platter. Several weeks ago at TheServerSide Java Symposium in Las Vegas the EJB expert group announced its decision to shelve the current entity bean architecture
and focus on the lightweight persistence of Plain Old Java Objects (POJOs). Specifically, it decided to use Hibernate as the persistence mechanism in EJB 3.0. Hibernate is an open source object/relational mapping solution that joined the JBoss Group last year.

13 Jan 2004

I like Hibernate. I built four of these systems , two of them as shipping products. Two Smalltalk, one C++, and one C. Some key findings:

1. OR mapping systems eliminate at least 30% of the development effort for an object system storing data in relational tables. At Easel we had data from 100s of large enterprises to support this number. A 1978 paper by F. King, an IBM Report on the Content of a Sample of Programs Surveyed found that 35% of code size of the database programs surveyed was due to mapping between program representations of data and database representations of data.

2. The uninitiated should not attempt to build these systems. In 1990, Gardner and Sutherland, in their Report on Buyer Furnished Equipment Development History and Level of Effort, showed that 35-55% of developer time on projects at Guiness Peat Aviation were devoted to hardcoding the mapping of objects to relational databases.

3. A good OR mapping system should allow the user to (1) autogenerate the database from the object model, (2) autogenerate the object model from a relational database, and (3) autobind an arbitrary object model to an arbitrary relational database. To do this you need a mapping file that you can manage with good tools.

4. Changes to the database for performance tuning should require no code changes in Java. The mapping file must autogen a new binding.

5. Performance should be better than hard coding by the typical developer. In no case should it be more than 10% slower than manual performance tuning by an expert.

Hibernate appears to support at least some of all of these features. For some good background reading, see the Hibernate external documentation page.

In 1989, what is now the front end of the Matisse object database was used as an object mapping layer for Oracle and demoed to the Oracle Product Management team. These were the first objects they had even seen in a relational database and they were particularly entranced by being able to search for images that looked like other images. The structure of this mapping has now been scanned online by ACM and published as:

The Hybrid Object-Relational Architecture (HORA): an integration of object-oriented and relational technology. Proceedings of the 1993 ACM/SIGAPP symposium on Applied computing: states of the art and practice table of contents, 1993
Jeff Sutherland, ODB, Cambridge, MA
Matthew Pope, Marcam, Canada
Ken Rugg, Object Design, Burlington, MA