jpa Single Table Inheritance Strategy


@InheritanceSpecifies type of inheritance strategy used
@DiscriminatorColumnSpecifies a column in database which will be used to identify different entities based on certain ID assigned to each entity
@MappedSuperClassmapped super classes are not persistent and only used to hold state for its subclasses. Generally abstract java classes are marked with @MapperSuperClass
@DiscriminatorValueA value specified in column defined by @DiscriminatorColumn. This value helps identify the type of entity


The advantage of single table strategy is it does not require complex joins for retrieval and insertion of entities, but on the other hand it wastes database space as many columns need to be nullable and there isn’t any data for them.

Complete example and article can be found here