인프런 영문 브랜드 로고
인프런 영문 브랜드 로고

인프런 커뮤니티 질문&답변

신동훈님의 프로필 이미지
신동훈

작성한 질문수

실전! 스프링 데이터 JPA

@EntityGraph

엔티티그래프 사용시 cross

작성

·

229

0

@EntityGraph(attributePaths = "professor")
@Query("select l from Lecture l where l.professor.name like %:professorName%")
List<Lecture> findLectureByProfessorName(@Param("professorName")String professorName);

위 코드를 작성하면

left outer join member professor2_ on lecture0_.member_id=professor2_.member_id cross join member professor1_

이런식으로 출력이 됩니다.

그러나 위 두개 대신

@Query("select l from Lecture l join fetch l.professor p where l.professor.name like %:professorName%")

이렇게 쓴다면

from lecture lecture0_ inner join member professor1_ on lecture0_.member_id=professor1_.member_id where professor1_.name like ?

이렇게 출력됩니다.

왜 저는 엔티티 그래프를 쓰면 크로스 조인이 발생할까요..?

답변 1

0

안녕하세요. 신동훈님, 공식 서포터즈 OMG입니다.

아래의 두 링크(모든 답변들)를 참고하시길 바랍니다 :)

 

참고

https://www.inflearn.com/questions/119902

https://www.inflearn.com/questions/151860

 

감사합니다.

신동훈님의 프로필 이미지
신동훈

작성한 질문수

질문하기