Table per Concrete Class in Hibernate Inheritance

Table per Concrete Class is one of the inheritance strategies in hibernate. In this tutorial we are going to implement the table per concrete class inheritance strategy. Here we are taking the same previous tutorial table per class strategy example like Card, Cheque and Payment classes.

If we want to store each concrete class objects of inheritance in separate tables of database then we can go with table per concrete class strategy in hibernate.

Table per Concrete Class Strategy:

What is concrete class?

In our example, we have 3 classes in the hierarchy called Payment, Card and Cheque. Here Card and Cheque classes are considered to be concrete classes. Because these classes are complete classes (We can create these objects and we can make use of them). Where as Payment class is not considered to be as concrete class because with out Card or Cheque there is no existence of Payment.

Example for Table per Concrete Class Strategy:

To implement the table per concrete class inheritance strategy in hibernate, we need to configure the all inheritance hierarchy classes in hbm.xml file. We need to configure the concrete classes with <union-subclass> tag under <class> tag.

Hi
Folks,
you have reach this so far, that shows you like what you are learning. Then why don't you support us to improve for bettor tutorials by leaving your valuable comments and why not you keep in touch with us for latest updates on your favorite blog @ facebook , twitter , Or Google+ ,