JPA comes with a provision to create tables and populate them as per the Java classes involved in inheritance. JPA offers basically three different approaches to map hierarchical classes – classes involved in inheritance with database tables. Observe, in the above hierarchy, three classes are involved where Person is the super class and Student and…

Posted in JPA

JPA Inheritance Strategy : Table Per Concrete Class Hierarchy (TABLE_PER_CLASS)

JPA comes with a provision to create tables and populate them as per the Java classes involved in inheritance. JPA offers basically three different approaches to map hierarchical classes – classes involved in inheritance with database tables. Observe, in the above hierarchy, three classes are involved where Person is the super class and Student and…

Posted in JPA

JPA Inheritance Strategy : Table Per Sub-Class Hierarchy (JOINED)

JPA comes with a provision to create tables and populate them as per the Java classes involved in inheritance. JPA offers basically three different approaches to map hierarchical classes – classes involved in inheritance with database tables. Observe, in the above hierarchy, three classes are involved where Person is the super class and Student and…

Posted in JPA

JPA Inheritance Strategy : Table Per Class Hierarchy (SINGLE_TABLE)

Hibernate comes with a provision to create tables and populate them as per the Java classes involved in inheritance. Hibernate offers basically three different approaches to map hierarchical classes – classes involved in inheritance with database tables. There are three types of inheritance strategy – Table per class hierarchy, Table per sub-class and Table per…

Posted in Hibernate

Inheritance Strategy in Hibernate

Introduction I am going to give explanation and example on hibernate table per class hierarchy. Let’s consider you have a base class named Person and two derived classes – Student and Teacher. If you save the derived class object like Student or Teacher then automatically Person class object will also be saved into the database,…

Posted in Hibernate

Hibernate Inheritance strategy: Table Per Class Hierarchy

Introduction In Table Per SubClass Hierarchy there will be the number of classes equals to the number of tables in the database. If you save the Student class object, hibernate will first save the data related to super class object into the super class related table in the database and then Student object data in…

Posted in Hibernate

Hibernate Inheritance strategy: Table Per SubClass Hierarchy

In Table Per Concrete Class Hierarchy will have the number of tables in the database equals to the number of derived classes. Once you save the derived class object, then derived class data and base class data will be saved in the derived class related table in the database. You need tables only for the…

Posted in Hibernate

Hibernate Inheritance strategy: Table Per Concrete Class Hierarchy