QCourseComment commentSub = new QCourseComment("commentSub"); JPQLQuery<Long> count = JPAExpressions .select(commentSub.count()) .from(commentSub) .where(commentSub.rootCommentId.eq(courseComment.id), commentSub.visibility.eq(Visibility.TRUE) ); List<CourseCommentForQueryDsl> fetch = jpaQueryFactory.select( Projections.constructor(CourseCommentForQueryDsl.class, courseComment.id, courseComment.comment, courseComment.rootCommentId, courseComment.createdAt, courseComment.updatedAt, count, courseComment.course.id, courseComment.course.title, courseComment.userId ))
QCourseCommnet를 새로 생성하여 조건에 맞는 count를 select에서 뽑아낼 수 있게 하였음.
여기서는 삭제되지 않은 subCourseCommnet의 개수를 구하기 위해 사용됌.