Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public interface PartnershipRepository extends JpaRepository<Partnership, Long>
or pd = :department
or (pc is null and pd is null)
)
and p.startDate >= current_date - 7
and (p.endDate is null or p.endDate >= current_date)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Partnership 엔티티에 @Where(clause = "start_date <= CURRENT_DATE AND end_date >= CURRENT_DATE") 어노테이션이 이미 적용되어 있어, 현재 활성화된 제휴만 필터링하고 있습니다. 따라서 이 JPQL 쿼리에서 (p.endDate is null or p.endDate >= current_date) 조건을 추가하는 것은 중복입니다. 또한, Partnership 엔티티의 endDate 필드는 @Column(nullable = false)로 정의되어 있어 p.endDate is null 조건은 항상 거짓이 됩니다. 코드의 명확성과 유지보수성을 위해 이 중복 조건을 제거하고 @Where 절에 필터링 로직을 일원화하는 것을 권장합니다.

""")
List<PartnershipRestaurant> findRestaurantsWithMyPartnerships(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ public interface PartnershipRestaurantRepository extends JpaRepository<Partnersh
LEFT JOIN FETCH pr.partnerships p
LEFT JOIN FETCH p.partnershipCollege
LEFT JOIN FETCH p.partnershipDepartment
WHERE p.startDate >= current_date - 7 and (p.endDate is null or p.endDate >= CURRENT_DATE)""")
WHERE p.endDate is null or p.endDate >= CURRENT_DATE""")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Partnership 엔티티에 @Where(clause = "start_date <= CURRENT_DATE AND end_date >= CURRENT_DATE") 어노테이션이 적용되어 있어, 이 JPQL 쿼리의 WHERE 절은 중복된 로직을 포함하고 있습니다. @Where 절이 이미 활성화된 제휴(partnership)만 가져오도록 필터링하므로, 이 WHERE 조건은 불필요합니다. 또한 PartnershipendDate 필드는 @Column(nullable = false)로 선언되어 있어 p.endDate is null 조건은 항상 거짓이므로 혼란을 줄 수 있습니다. 필터링 로직을 @Where 절로 일원화하여 코드의 일관성을 높이고 중복을 제거하는 것을 제안합니다.

Suggested change
WHERE p.endDate is null or p.endDate >= CURRENT_DATE""")
""")

List<PartnershipRestaurant> findAllWithDetails();
}