diff --git a/backend/src/main/java/reviewme/highlight/domain/exception/NegativeHighlightIndexException.java b/backend/src/main/java/reviewme/highlight/domain/exception/NegativeHighlightIndexException.java index 9d2a32f00..0b453a406 100644 --- a/backend/src/main/java/reviewme/highlight/domain/exception/NegativeHighlightIndexException.java +++ b/backend/src/main/java/reviewme/highlight/domain/exception/NegativeHighlightIndexException.java @@ -7,7 +7,7 @@ public class NegativeHighlightIndexException extends BadRequestException { public NegativeHighlightIndexException(long startIndex, long endIndex) { - super("하이라이트 위치는 1 이상의 수이어야 해요."); + super("하이라이트 위치는 0 이상의 수이어야 해요."); log.info("Highlight index is a negative number - startIndex: {}, endIndex: {}", startIndex, endIndex); } } diff --git a/backend/src/main/java/reviewme/highlight/repository/HighlightRepository.java b/backend/src/main/java/reviewme/highlight/repository/HighlightRepository.java index c914d9750..1798d616f 100644 --- a/backend/src/main/java/reviewme/highlight/repository/HighlightRepository.java +++ b/backend/src/main/java/reviewme/highlight/repository/HighlightRepository.java @@ -1,7 +1,17 @@ package reviewme.highlight.repository; +import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Modifying; +import org.springframework.data.jpa.repository.Query; import reviewme.highlight.domain.Highlight; public interface HighlightRepository extends JpaRepository { + + @Modifying + @Query(""" + DELETE FROM Highlight h + WHERE h.answerId IN :answersByReviewQuestion + """) + void deleteAllByIds(List answersByReviewQuestion); } diff --git a/backend/src/main/java/reviewme/highlight/service/HighlightService.java b/backend/src/main/java/reviewme/highlight/service/HighlightService.java index d123cff8a..e81f8414d 100644 --- a/backend/src/main/java/reviewme/highlight/service/HighlightService.java +++ b/backend/src/main/java/reviewme/highlight/service/HighlightService.java @@ -46,7 +46,7 @@ private void deleteOldHighlight(long questionId, long reviewGroupId) { .map(Answer::getId) .toList(); - highlightRepository.deleteAllById(answersByReviewQuestion); + highlightRepository.deleteAllByIds(answersByReviewQuestion); } private void saveNewHighlight(HighlightsRequest highlightsRequest) {