<aside> ❗

JPA의 데이터 타입 분류

[엔티티 타입]

[값 타입]

<aside> ❗

값 타입 분류

기본값 타입 - 사이드 이펙트 없이 개발 가능

<aside> ❗

기본값 타입

<aside> ❗

자바의 기본 타입은 절대 공유 X

</aside>

<aside> ❗

임베디드 타입(복합 값 타입) - 내장타입

<aside> ❗

임베디드 타입

image.png

<aside> ❗

임베디드 타입

image.png

image.png

</aside>

<aside> ❗

임베디드 타입 사용법

<aside> ❗

임베디드 타입의 장점

<aside> ❗

임베디드 타입과 테이블 매핑

image.png

@Entity
public class Member extends BaseEntity{

    @Id
    @GeneratedValue
    @Column(name = "MEMBER_ID")
    private Long id;

    private String name;

    @Embedded
    private Period workPeriod;

    @Embedded
    private Address homeAddress;
 }
@Embeddable
public class Period {

    LocalDateTime startDate;
    LocalDateTime endDate;

    public Period() {

    }
    ...
}
@Embeddable
public class Address {
    private String city;
    private String street;
    private String zipcode;

    public Address() {

    }

    public Address(String city, String street, String zipcode) {
        this.city = city;
        this.street = street;
        this.zipcode = zipcode;
    }
    ...
}

</aside>