Inheritence

Abstract Entity

Abstract class can be annotated @Entity;

  • like concrete entity,

  • cannot be instantiated,

  • can be queried

Mapped Superclass

@MappedSuperclass - contains mapping information but

  • not persisted entity

  • cannot be queried

  • must use sub-class, not this (super) class

  • cannot be target of relationship

  • has no corresponding table in db

Mapping Strategies

@Inheritence (strategy = ) on root class

  • SINGLE_TABLE

    • default

    • has discriminatory column to tell subclass

    • @DiscriminatoryColumn (study further...)

  • TABLE_PER_CLASS

    • support is optional (not all server supports this)

    • poor on polymorphic relationships

  • JOIN - table for parent class joins table for children

    • may lead to poor performance