Inheritance Mapping In Hibernate

There are three inheritance mapping strategies defined in the hibernate:

  1. Table per class hierarchy
  2. Table per sub-class hierarchy
  3. Table per concrete class hierarchy

The relational model supported by Hibernate is “has-a” relationship. How Hibernate writes tables for the Java classes involved in inheritance?

Hibernate comes with a provision to create tables and populate them as per the Java classes involved in inheritance. Hibernate offers basically 3 different approaches to map hierarchical classes (classes involved in inheritance) with database tables. Here, we have classes but no tables. Tables are created by Hibernate automatically.

Compared to JDBC we have one main advantage in hibernate, which is hibernate inheritance.  Suppose if we have base and derived classes, now if we save derived(sub) class object, base class object will also be stored into the database.We will see each of this in details in next post



Comments are closed