Hibernate Inheritance – Table Per Class Hierarchy (XML Mapping & Annotation)

Java being an Object Oriented Language, it supports one of the most powerful concept “Inheritance“. Object Oriented Systems generally supports both IS-A and HAS-A relationships, whereas Relational Model supports only HAS-A relationship. Hibernate can help you map such kind of entities into the Relational table based on the strategy selected.

Types of Inheritance in Hibernate

Hibernate offers 3 different approaches for mapping this kind of hierarchical classes.

  1. Table per Class hierarchy
  2. Table per Sub-Class hierarchy
  3. Table per Concrete Class hierarchy

[Read more…]

Hibernate One-to-One Bidirectional Mapping Example – Foreign Key(Annotation)

In this article, we will learn how to achieve Hibernate One-to-One Bidirectional Mapping using the JPA Annotations with Foreign Key, in the previous One-To-One Bidirectional Mapping Example we used only the Primary Key. This Annotation approach is just an alternative to the XML mapping which we used in our earlier article Hibernate One-To-One Mapping XML Example with Foreign Key
[Read more…]