Entity inheritance
For several years we hear the term impedance mismatch, which describes the difficulties in bridging the object and relational worlds. In regard to inheritance, unfortunately, there is no natural and efficient way to represent an inheritance relationship in a relational database.
JPA introduces three strategies to support inheritance:
| Single table-This strategy maps all classes in the hierarchy to the base class table. This means that the table contains the superset of all the data contained in the class hierarchy. For an example of single table inheritance, refer to Adding inheritance.
|
| Joined tables-With this strategy, the top level entry in the entity hierarchy is mapped to a table that contains columns common to all the entities, while each of the other entities down the hierarchy are mapped to a table that contain only columns specific to that entity.
|
| Table per class-With this strategy, both the superclass and subclasses are stored in their own table and no relationship exists between any of the tables. Therefore, all the entity data are stored in their own tables.
|