Created
September 6, 2021 15:17
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 단일 테이블 전략 | |
* create table Item ( | |
* DTYPE varchar(31) not null, | |
* id bigint not null, | |
* brand varchar(255), | |
* price integer not null, | |
* hasHipassYn varchar(255), | |
* isElectronicYn varchar(255), | |
* cargoWeight integer, | |
* source varchar(255), | |
* destination varchar(255), | |
* primary key (id) | |
* ) | |
*/ | |
@Entity | |
@Inheritance(strategy = InheritanceType.SINGLE_TABLE) | |
@DiscriminatorColumn // 단일 테이블 전략의 경우 해당 어노테이션 없어도 생성됨 | |
@Getter | |
@Setter | |
public class Vehicle { | |
@Id | |
@GeneratedValue | |
private Long id; | |
private String brand; | |
private int price; | |
} | |
@Entity | |
@Getter | |
@Setter | |
public class Car extends Vehicle { | |
private String hasHipassYn; | |
private String isElectronicYn; | |
} | |
@Entity | |
@Getter | |
@Setter | |
public class Truck extends Vehicle { | |
private int cargoWeight; | |
private String source; | |
private String destination; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment