Why Object/Relational Mapping?
Let's take a look at what the difference between an object and a relational model means. First, an example of object inheritance, as shown in Figure 1.1.

Consider the data associated with these objects. For example, you may wish to store the fang length for the mammals, and the number of fins on the fish, but you're also keeping track of the height and weight that you would track for all animals. Expressing this hierarchical relationship in an object-oriented programming language is easy, convenient, and efficient.
Relational databases, in comparison, view data in terms of tables. Structured Query Language (SQL) is the standard mechanism for interaction with a relational database. Most critically, data is viewed in terms of tables, columns, and rows. Relational capabilities allow multiple tables to be integrated and perform sophisticated data retrieval, allowing powerful mining and reporting capabilities.
Unfortunately, it is surprisingly difficult to map the tables and queries one might express in SQL to the hierarchical, object-oriented capabilities of a modern programming language. To store the data associated with an object hierarchy, as shown in Figure 1.1, in a database could require as many as seven tables, with many complex SQL statements required to perform the retrieval of all of the data associated with a single halibutor a single table with many unused fields, depending on the record entry. Hibernate allows you to easily use any of these potential database structures seamlessly and naturally from Java.
 |