Skip to content

Commit

Permalink
refactor : Fetch Join 사용으로 n+1이슈 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
Dayon-Hong committed May 28, 2024
1 parent dc8a34a commit 136eb12
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@

public interface ScheduleRepository extends JpaRepository<Schedule, Long> {
Optional<Schedule> findByIdAndActivatedIsTrue(Long scheduleId);
@Query("SELECT s FROM Schedule s WHERE s.member = :member AND s.activated = true ORDER BY s.updatedAt DESC")
@Query("SELECT s FROM Schedule s LEFT JOIN FETCH s.country WHERE s.member = :member AND s.activated = true ORDER BY s.updatedAt DESC")
List<Schedule> findSchedulesByMember(@Param("member") Member member);
List<Schedule> findTop5ByMemberOrderByIdDesc(Member member);
@Query("SELECT s FROM Schedule s LEFT JOIN FETCH s.scheduleDetails WHERE s.member = :member ORDER BY s.id DESC")
List<Schedule> findTop5ByMemberOrderByIdDescWithDetails(@Param("member") Member member);


}

0 comments on commit 136eb12

Please sign in to comment.