Skip to content

Commit

Permalink
fix: delete문 cross join 문제 native query를 통해 오류 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
kjungw1025 committed Dec 22, 2023
1 parent 6f1857f commit b8d848e
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@ public interface DiaryRepository extends JpaRepository<Diary, Long> {
"(d.diaryDate between TO_DATE(:curDate, 'YYYY/MM') and TO_DATE(:nextDate, 'YYYY/MM'))")
List<Diary> findByDate(Long memberId, String curDate, String nextDate);

@Transactional
@Modifying
@Query("delete from Diary d " +
"where d.member.id = :memberId and " +
"d.member.status = 'ACTIVE' and " +
"d.id = :diaryId ")
@Query(value = "delete from diary " +
"where member_id = (select member_id from member where member_id = :memberId and status = 'ACTIVE') and " +
"diary_id = :diaryId ", nativeQuery = true)
void deleteByDate(Long memberId, Long diaryId);
}

0 comments on commit b8d848e

Please sign in to comment.