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

[BE] fix: delete 쿼리가 한 번만 나가도록 jpql을 사용한다. #833

Closed
wants to merge 2 commits into from
Closed
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 @@ -7,7 +7,7 @@
public class NegativeHighlightIndexException extends BadRequestException {

public NegativeHighlightIndexException(long startIndex, long endIndex) {
super("하이라이트 위치는 1 이상의 수이어야 해요.");
super("하이라이트 위치는 0 이상의 수이어야 해요.");
Copy link
Contributor

Choose a reason for hiding this comment

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

귣귣

log.info("Highlight index is a negative number - startIndex: {}, endIndex: {}", startIndex, endIndex);
}
}
Original file line number Diff line number Diff line change
@@ -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<Highlight, Long> {

@Modifying
@Query("""
DELETE FROM Highlight h
WHERE h.answerId IN :answersByReviewQuestion
""")
void deleteAllByIds(List<Long> answersByReviewQuestion);
Comment on lines +11 to +16
Copy link
Contributor

Choose a reason for hiding this comment

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

아이 해브 어 퀘스티온~!!

전과 후에 delete 쿼리가 어떻게 바뀌는지 좀 더 설명해주실 수 있나요?🥹

}
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down