Inheritance - rafalkieras/jpa-kss GitHub Wiki

#Inheritance

##Mapped superclass

@MappedSuperclass - designates a class whose mapping information is applied to the entities that inherit from it. A mapped superclass has no separate table defined for it.

##Single table

InheritanceType.SINGLE_TABLE - there is only one table and it contains all the fields of the all classes in the hierarchy. This is the default strategy.

This table has a discriminator column containing a value that identifies the subclass to which the instance represented by the row belongs.

Single table

##Joined

InheritanceType.JOINED - there is a table for each class, tables for subclasses contain only those fields that are specific to those classes.

Joined strategy

##Table per class

InheritanceType.TABLE_PER_CLASS - there is a table for each concrete class (non-abstract) class and each table contains all the fields (for the superclasses as well). Support for this strategy is optional and may not be supported by all Java Persistence API providers.

Table per class