강의

멘토링

커뮤니티

Inflearn Community Q&A

jungflasher0783's profile image
jungflasher0783

asked

Real-world! Spring Boot and JPA Utilization 2 - API Development and Performance Optimization

fetch 전략 동적 선택

Written on

·

218

0

@ManyToOne 관계나 @OneToMany 관계에서 fetch 전략을 동적으로 결정할 수 는 없을까요..

일을하다 보면 상황에 따라서  lazy, eager 가 달라지는데 

특정 메소드를 호출할때 fetch 전략을 lazy 로 할지 eager 로 할지 결정할 수는 없나요?

spring-bootspringJPAjava

Answer 2

1

jungflasher0783님의 프로필 이미지
jungflasher0783
Questioner

네 감사합니다.

0

yh님의 프로필 이미지
yh
Instructor

안녕하세요. 정재훈님 좋은 질문입니다^^!

결론부터 말씀드리면 모든 연관관계는 LAZY를 설정해야 합니다.

그리고 꼭 필요한 상황에 맞추어 fetch join등을 사용해서 한번에 조회하는 방식으로 사용하는 것이 좋습니다.

기본편에서 이런 부분들도 자세히 설명드리니 기본편을 꼭 수강하시길 권장드립니다^^!

jungflasher0783's profile image
jungflasher0783

asked

Ask a question