Inheritance Mapping In Hibernate – Introduction

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.
But the thing is we must specify in what table we need to save which object data ( i will explain about this point later, just remember as of now).

For Example:

1234class Payment
{
   // content will goes here
}
1234class CreditCard extends Payment
{
   // content will goes here
}
  • See if you save CreditCard class object, then payment class object will also be saved into the database

Hibernate supports 3 types of Inheritance Mappings:

  • Table per class hierarchy
  • Table per sub-class hierarchy
  • Table per concrete class hierarchy

Note: We can also called this Hibernate Inheritance Mapping as Hibernate Hierarchy

Will see these 3 Inheritance Mappings in depth___, friends ensure you are clear about all previous concepts so far we covered, if not so you may not understand further, please refer once if you have any doubts.

Related Articles

post a comment