Object Relational Impedance Mismatch

In my previous post Object Relational Mapping I talked about the rise of OR mappers like Hibernate. Theoretical foundation between OR mappers is the fact that modelling in objects and modelling in entities has some key differences referred to as the Object Relational Impedance Mismatch.

Application structure and views are typically very similar to the way your database is structured. For example in a management application you usually have a list view with search options, a detail view and edit screens or tabs. Now this relates pretty close to SELECT statements (with WHERE clauses) and individual update statement. Making an mapping from the database to an object model first gives you two mismatches you need to work on. One between database and object model and one between object model and screen.

I can hold a similar story for import/export functionality. The files you use a similar to your database and not to your object model.

OR Mapping frameworks are a performance degrader for tracking lists of objects, as long as these objects are alive the framework must track these objects until they are discarded and at that point verify that no changes must be committed to the database.

My suggestion is to use hibernate to map real world application constructs, like a list view, and only map objects in your theoretical object model.


%d bloggers like this: