Advertisement



< 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

Please subscribe to our social media channels for daily updates.


Decodejava Facebook Page  DecodeJava Twitter Page Decodejava Google+ Page




Advertisement



Notifications



Please check our latest addition

C#, PYTHON and DJANGO


Advertisement