Spring Framework/JPA
@Embeddable 사용 이유와 장점
devstep
2022. 6. 4. 21:00
@Embeddable 사용한 이유와 장점
관련성이 있는 값들을 의미 있는 객체로 묶어서 관리하면서 객체의 응집도가 높아지는 효과를 기대하고 사용.
공유할 수 있는 객체 이면서 변경할 수 없도록(불변) 사용가능한 것이 @Embedded 타입의 장점이라고 생각합니다.
import javax.persistence.Embeddable;
@Embeddable
public class Address {
private String country;
private String city;
private String gu;
}