015. Inheritance - dkkahm/study-spring-jpa GitHub Wiki

InheritanceType

  • SINGLE_TABLE (default)
  • TABLE_PER_CLASS
  • JOINED

Entities

  • Employee
@Entity
// @Inheritance(strategy = InheritanceType.SINGLE_TABLE)
// @DiscriminatorColumn(name="DTYPE")
public abstract class Employee {
    @Id
    @GeneratedValue
    private Long id;

    private String name;
  • PartTimeEmployee
@Entity
public class PartTimeEmployee extends Employee {

    private BigDecimal hourlyWage;
  • FullTimeEmployee
@Entity
public class FullTimeEmployee extends Employee {

    private BigDecimal salary;