< Prev
Next >



SingleTable Inheritance with Annotation



In our last article, we performed mapped inheritance between classes to database using Hibernate. By default, Hibernate uses a single table strategy to perform inheritance between the classes. And, there is another way through which Hibernate performs implement inheritance using single table inheritance i.e. by using specific annotations with Hibernate.

Today we are going to understand how to map inheritance between the classes to the database using annotations with Hibernate. By using annotations, we can configure the table name, column name and the values in dtype column of the single table created by Hibernate to implement inheritance.

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 annotations.




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
-
Python

Ad2