owning side
-
JPA 연관 관계의 주인과 소유 측: 개념 및 예제JPA 2024. 5. 4. 18:26
JPA 연관 관계에 대한 학습을 하다보면 관계의 주인이라는 표현이 나온다.이에 대해 자세히 알아보자.예제 코드// In Customer class:@OneToMany(mappedBy="customer")private Set orders;// In Order class:@ManyToOneprivate Customer customer;The owner of the relationship (관계의 주인)"관계의 주인(The owner of the relationship)"은 엔티티 클래스 자체가 아니라, 관계를 관리하는 필드 또는 프로퍼티를 의미한다.JPA의 레퍼런스 어디에서도 엔티티 클래스에 owner라는 표현을 쓰지 않는다.예제 코드에서 Order 클래스의 customer 필드가 관계의 주인이다.이는 외래..