Skip to content

Commit

Permalink
fix: jpa type 에러, 엔티티 lazy 조회 이슈 해결 (#184)
Browse files Browse the repository at this point in the history
  • Loading branch information
kimJH47 authored Feb 23, 2024
1 parent 9af5087 commit 59f7705
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,17 @@ public void deleteComment(final Long memberId, final Long commentId) {
final Comment comment = getCommentById(commentId);
validateDeleteAuthority(comment.getCommenter().getId(), memberId);
if (comment.isComment()) {
Long deleteComment = commentRepository.countByParentComment(comment) + 1;
long deleteComment = commentRepository.countByParentComment(comment) + 1;
Vote vote = comment.getVote();
vote.decreaseCommentCount(Math.toIntExact(deleteComment));
commentRepository.deleteAllRepliesByParentCommentId(commentId);
voteRepository.decreaseCommentCount(comment.getVote().getId(), deleteComment);
commentRepository.delete(comment);
return;
}

Comment parentComment = comment.getParentComment();
commentRepository.decreaseReplyCount(commentId);
voteRepository.decreaseCommentCount(comment.getVote().getId());
voteRepository.decreaseCommentCount(parentComment.getVote().getId());
commentRepository.delete(comment);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,4 @@ public interface VoteRepository extends Repository<Vote, Long>, VoteRepositoryCu
"v.evaluationCount = v.evaluationCount - 1 " +
"where v.id = :id")
void updateVoteEvaluationsStatisticsForEvaluationDisLikeDelete(Long id);

@Modifying(clearAutomatically = true, flushAutomatically = true)
@Query(value = "update Vote v set v.commentCount = v.commentCount - :count where v.id = :id")
void decreaseCommentCount(Long id,Long count);
}

0 comments on commit 59f7705

Please sign in to comment.