diff --git a/src/main/java/de/bstly/board/businesslogic/CommentManager.java b/src/main/java/de/bstly/board/businesslogic/CommentManager.java index 7c700c3..1320042 100644 --- a/src/main/java/de/bstly/board/businesslogic/CommentManager.java +++ b/src/main/java/de/bstly/board/businesslogic/CommentManager.java @@ -95,10 +95,16 @@ public class CommentManager { JPAQuery countQuery = query.clone().select(qComment.id.countDistinct()); + Long count = countQuery.fetchOne(); + + if (count == null) { + count = 0L; + } + return new PageImpl(query .orderBy(new OrderSpecifier<>( asc ? com.querydsl.core.types.Order.ASC : com.querydsl.core.types.Order.DESC, qComment.created)) - .limit(size).offset(page * size).fetch(), PageRequest.of(page, size, sort), countQuery.fetchOne()); + .limit(size).offset(page * size).fetch(), PageRequest.of(page, size, sort), count); } /** diff --git a/src/main/java/de/bstly/board/businesslogic/EntryManager.java b/src/main/java/de/bstly/board/businesslogic/EntryManager.java index a208066..617e8e8 100644 --- a/src/main/java/de/bstly/board/businesslogic/EntryManager.java +++ b/src/main/java/de/bstly/board/businesslogic/EntryManager.java @@ -414,10 +414,16 @@ public class EntryManager { JPAQuery countQuery = query.clone().select(qEntry.id.countDistinct()); + Long count = countQuery.fetchOne(); + + if (count == null) { + count = 0L; + } + return new PageImpl(query .orderBy(new OrderSpecifier<>( asc ? com.querydsl.core.types.Order.ASC : com.querydsl.core.types.Order.DESC, qEntry.created)) - .limit(size).offset(page * size).fetch(), PageRequest.of(page, size, sort), countQuery.fetchOne()); + .limit(size).offset(page * size).fetch(), PageRequest.of(page, size, sort), count); } /**