Inheritance
  • Entity classes can extend other entity classes
Entity Inheritance Example  
  @Entity
  public abstract class Employee { // Queryable!
    ...
  }

  @Entity
  public class PartTimeEmployee extends Employee { // Queryable!
    ...
  }

  @Entity
  public class FullTimeEmployee extends Employee { // Queryable!
    ...
  }
  • Non-entity superclasses having the @MappedSuperclass annotation will have their persistent state stored
@MappedSuperclass Inheritance Example  
  • Non-entity superclasses should be used to inherit behavior only, as their state is not persisted
Non-Entity Inheritance Example