1. JPA 연관관계 설정방법
- JPA 의 경우는 Enitity 클래스의 필드 위에 연관관계 어노테이션 (@) 을 설정해 주는 것만으로 연관관계가 형성됩니다!
- '음식 배달 서버'를 개발한다고 가정
- 중요) 항상 Enitity 본인 중심으로 관계를 생각!
주문
@Enitity
public class Order {
@OneToMany
private List<Food> foods;
@OneToOne
private Coupon coupon;
}
음식 점주
@Entity
public class Owner {
@ManyToOne
Restaurant restaurant;
}
고객
@Entity
public class User{
@ManyToMany
List<Restaurant> pickRestaurants;
}
'프로그래밍 > SpringBoot' 카테고리의 다른 글
data.sql 사용법 - 스프링부트 실행시 init으로 쿼리 실행하기 (0) | 2022.07.02 |
---|---|
list 값 줄별로 출력하기 forEach(System.out::Println) (0) | 2022.07.02 |
JPA 연관관계를 이용한 폴더 테이블 설계 (0) | 2022.06.17 |
Spring Data Jpa 페이징 (0) | 2022.06.16 |
Spring Data JPA (0) | 2022.06.08 |