< Prev
Next >



Hibernate mapping Single Table Inheritance



Today we are going to understand how to map inheritance between the classes to the database using Hibernate. As you already know, inheritance is used when a class wants to use/inherit the features of another existing class.

The class that wants to use the feature of another class, is called subclass, whereas the class whose features are to be used/inherited is referred to as superclass. A class inheriting from another class, can access its features and can also add its own specific features.

Let's take an example of an Entity class - Country, which is extended by two classes AsianCountry and EurpoeanCountry. By default, Hibernate performs the inheritance between classes by combining all of their objects under single table and this strategy is also called Single Table Strategy. Now, let's see how Hibernate performs object-relational-mapping(ORM) to represent the inheritance between these three classes in the database.




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