개발일기장

embedded type 관리 본문

Spring Boot/JPA

embedded type 관리

게슬 2021. 1. 30. 12:10
728x90

MEMBER 객체 안에 

 

    @Embedded
    private Address address;

이런게 있는데 이거는 

 

package jpabook.jpashop.domain;

import lombok.Getter;

import javax.persistence.Embeddable;

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

    protected Address() {
    }

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

 

이것을 내장한다는 말이고, ADDRESS 객체는 다른곳에만 들어간다는 뜻임

@Embeddable이나, @Embedded 둘중 하나만 집어넣으면 됨

 

그 뭐지 다중값속성이였나 이거 해결하기 위해서 있는거같음.

그리고 ADDRESS 자체를 다른곳에서도 이용할 수 있게 한것,..

728x90

'Spring Boot > JPA' 카테고리의 다른 글

DTO이용해서 entity 참조 된거 보내기  (0) 2021.02.06
ENUM type 관리  (0) 2021.01.30
일반적인 Entity  (0) 2021.01.30
Spring JPA강의들은거 기록  (0) 2021.01.30
Comments