diff --git a/src/main/java/solitour_backend/solitour/information/repository/InformationRepositoryImpl.java b/src/main/java/solitour_backend/solitour/information/repository/InformationRepositoryImpl.java index 8bdb852..49a38c4 100644 --- a/src/main/java/solitour_backend/solitour/information/repository/InformationRepositoryImpl.java +++ b/src/main/java/solitour_backend/solitour/information/repository/InformationRepositoryImpl.java @@ -249,14 +249,16 @@ private OrderSpecifier getOrderSpecifier(String sort, NumberPath inform return information.createdDate.desc(); } - private NumberExpression countGreatInformationByInformationById(NumberPath informationId) { + private NumberExpression countGreatInformationByInformationById(NumberPath informationId) { QGreatInformation greatInformationSub = QGreatInformation.greatInformation; JPQLQuery likeCountSubQuery = JPAExpressions .select(greatInformationSub.count()) .from(greatInformationSub) .where(greatInformationSub.information.id.eq(informationId)); // 파라미터로 받은 NumberPath와 비교 - return Expressions.asNumber(likeCountSubQuery).longValue(); // 명확하게 Long 타입 반환 + return Expressions.numberTemplate(Long.class, "{0}", likeCountSubQuery) + .coalesce(0L) + .intValue(); } private BooleanExpression isUserGreatInformation(Long userId) {