클래스의 상속 구조와 데이터베이스 테이블 간의 상속 구조를 매핑
import javax.persistence.*;
@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
public class Vehicle {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
// 공통 필드 및 메서드
}
@Entity
public class Car extends Vehicle {
private String model;
// Car 클래스의 필드 및 메서드
}
@Entity
public class Truck extends Vehicle {
private double payloadCapacity;
// Truck 클래스의 필드 및 메서드
}
InheritanceType.JOINED
InheritanceType.SINGLE_TABLE
InheritanceType.TABLE_PER_CLASS
JPA repository들을 활성화하여 빈으로 등록한다. 기본적으로 @Configuration가 붙은 클래스의 하위 패키지를 스캔한다.
TO BE CONTINUED...
@Inherited
https://codeung.tistory.com/259