diff --git a/src/main/java/com/api/ttoklip/domain/newsletter/post/repository/NewsletterQueryDslRepositoryImpl.java b/src/main/java/com/api/ttoklip/domain/newsletter/post/repository/NewsletterQueryDslRepositoryImpl.java index 0e91f0ac..a2608c63 100644 --- a/src/main/java/com/api/ttoklip/domain/newsletter/post/repository/NewsletterQueryDslRepositoryImpl.java +++ b/src/main/java/com/api/ttoklip/domain/newsletter/post/repository/NewsletterQueryDslRepositoryImpl.java @@ -58,6 +58,10 @@ private BooleanExpression getActivatedNewsletter() { return newsletter.deleted.isFalse(); } + private BooleanExpression getActivatedNewsletterFromComments() { + return newsletterComment.newsletter.deleted.isFalse(); + } + @Override public Newsletter findByIdFetchJoin(Long newsletterPostId) { Newsletter findNewsletter = jpaQueryFactory @@ -80,10 +84,10 @@ public List findActiveCommentsByNewsletterId(Long newsletterI return jpaQueryFactory .selectFrom(newsletterComment) .distinct() - .leftJoin(newsletter.member, member).fetchJoin() + .leftJoin(newsletterComment.member, member).fetchJoin() .where( matchNewsletterId(newsletterId), - getActivatedNewsletter() + getActivatedNewsletterFromComments() ) .orderBy( newsletterComment.parent.id.asc().nullsFirst(), @@ -92,6 +96,7 @@ public List findActiveCommentsByNewsletterId(Long newsletterI .fetch(); } + private BooleanExpression matchNewsletterId(final Long newsletterId) { return newsletterComment.newsletter.id.eq(newsletterId); }