< Prev
Next >



Inheritance by Joined Strategy



In our last article, we performed mapped inheritance between the classes to database using Hibernate's table per class strategy. In this article, we are going to show you how to perform inheritance using Hibernate's joined strategy.

Using the joined strategy will create a separate table for parent class and a separate table for each of its child classes and the child classes will remain with the specific properties mentioned in them while the inherited properties of parent class are going to remain with the parent class only, except the primary key of the parent class which will become a foreign key in the child classes.

Let's take the same example of an Entity class - Country, which is extended/inherited by two classes AsianCountry and EurpoeanCountry. Now, let's see how Hibernate performs object-relational-mapping(ORM) to represent the inheritance between these three classes in the database, by using joined strategy.




Note :


Please subscribe our social media channels for notifications, we post a new article everyday.

Decodejava Google+ Page Decodejava Facebook Page  DecodeJava Twitter Page

Coming Next
-
C++ and Python

Ad2