Chapter 2. Fundamentals

In the previous chapter, we walked through a basic example of persisting Movie objects using the Hibernate framework. We skipped over the details, as our aim was to get a quick taste of Hibernate without having to worry about the ingredients. Now is the time to learn the fundamentals of the framework to cement these foundations. This chapter deals with such fundamentals.

But before we go into those Hibernate details, there’s one thing you should understand first: the core problem of the object-relational model mismatch (which is the very reason why ORM was developed in the first place).

Object-Relational Mismatch

In an object-relational persistence world, no discussion would be complete without a grasp of the object-relational paradigm mismatch. Understanding this paradigm will give you some insight into the inception and existence of ORM tools.

The object world is designed to solve specific problems: booking a flight, transferring money, shopping for books, and so on. Technical solutions are designed with a domain model in mind to solve these problems. The domain model defines the objects representing a real-world problem. A flight reservation, bank account, and book search are examples of domain objects. These domain objects are expected to be stored and retrieved from a database.

Most of the real-world applications cannot exist without some form of persistence. We would go crazy if our banks said that they lost our money because they hadn’t stored our deposits ...

Get Just Hibernate now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.