fix nullpointer

This commit is contained in:
_Bastler 2022-04-13 21:43:26 +02:00
parent d3b2a95472
commit 95376a2369
2 changed files with 14 additions and 2 deletions

View File

@ -95,10 +95,16 @@ public class CommentManager {
JPAQuery<Long> countQuery = query.clone().select(qComment.id.countDistinct()); JPAQuery<Long> countQuery = query.clone().select(qComment.id.countDistinct());
Long count = countQuery.fetchOne();
if (count == null) {
count = 0L;
}
return new PageImpl<Comment>(query return new PageImpl<Comment>(query
.orderBy(new OrderSpecifier<>( .orderBy(new OrderSpecifier<>(
asc ? com.querydsl.core.types.Order.ASC : com.querydsl.core.types.Order.DESC, qComment.created)) 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);
} }
/** /**

View File

@ -414,10 +414,16 @@ public class EntryManager {
JPAQuery<Long> countQuery = query.clone().select(qEntry.id.countDistinct()); JPAQuery<Long> countQuery = query.clone().select(qEntry.id.countDistinct());
Long count = countQuery.fetchOne();
if (count == null) {
count = 0L;
}
return new PageImpl<Entry>(query return new PageImpl<Entry>(query
.orderBy(new OrderSpecifier<>( .orderBy(new OrderSpecifier<>(
asc ? com.querydsl.core.types.Order.ASC : com.querydsl.core.types.Order.DESC, qEntry.created)) 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);
} }
/** /**