Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[20210625] @EntityGraph #158

Open
JuHyun419 opened this issue Jun 25, 2021 · 0 comments
Open

[20210625] @EntityGraph #158

JuHyun419 opened this issue Jun 25, 2021 · 0 comments
Labels

Comments

@JuHyun419
Copy link
Owner

JuHyun419 commented Jun 25, 2021

JPA - @entitygraph

  • 엔티티의 특정 속성을 같이 로딩하도록 표시하는 어노테이션
    • attributePaths: 로딩 설정을 변경하고 싶은 속성의 이름을 배열로 명시
    • type: @entitygraph를 어떤 방식으로 적용할 것인지 설정
      • FATCH 속성값은 attributePaths에 명시한 속성은 EAGER로 처리하고, 나머지는 LAZY로 처리
      • LOAD 속성값은 attributePaths에 명시한 속성은 EAGER로 처리하고, 나머지는 엔티티 클래스에 명시되거나 기본 방식으로 처리
    //Repository
    @EntityGraph(attributePaths = {"member"}, type = EntityGraph.EntityGraphType.FETCH)
    List<Review> findByMovie(Movie movie);

    // Review Entity
    @ManyToOne(fetch = FetchType.LAZY)
    private Member member;

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant