diff --git a/src/main/java/com/projectlyrics/server/domain/note/repository/impl/QueryDslNoteQueryRepository.java b/src/main/java/com/projectlyrics/server/domain/note/repository/impl/QueryDslNoteQueryRepository.java index b738e8b4..6e65cb4e 100644 --- a/src/main/java/com/projectlyrics/server/domain/note/repository/impl/QueryDslNoteQueryRepository.java +++ b/src/main/java/com/projectlyrics/server/domain/note/repository/impl/QueryDslNoteQueryRepository.java @@ -54,15 +54,20 @@ public Optional findById(Long id, Long userId) { .join(note.publisher).fetchJoin() .join(note.song).fetchJoin() .join(song.artist).fetchJoin() - .leftJoin(note.comments, comment).fetchJoin() - .leftJoin(block) - .on(block.blocked.eq(comment.writer) - .and(block.blocker.id.eq(userId)) - .and(block.deletedAt.isNull())) + .leftJoin(note.comments, comment) + .on(comment.deletedAt.isNull() + .and(comment.writer.id.notIn( + JPAExpressions.select(block.blocked.id) + .from(block) + .where( + block.blocker.id.eq(userId), + block.deletedAt.isNull() + ) + )) + ).fetchJoin() .where( note.id.eq(id), - note.deletedAt.isNull(), - block.id.isNull() + note.deletedAt.isNull() ) .fetchOne() );