Skip to content

Commit b99ed24

Browse files
[fix] Remove JOIN FETCH when using COUNT query (#68)
Previous versions of Spring still need this check.
1 parent da86c5d commit b99ed24

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/main/java/org/springframework/data/jpa/datatables/SpecificationBuilder.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ private class DataTablesSpecification<S> implements Specification<S> {
2727
public Predicate toPredicate(Root<S> root, CriteriaQuery<?> query, CriteriaBuilder criteriaBuilder) {
2828
initPredicatesRecursively(tree, root, root, criteriaBuilder);
2929

30+
boolean isCountQuery = query.getResultType() == Long.class;
31+
if (isCountQuery) {
32+
root.getFetches().clear();
33+
}
34+
3035
return createFinalPredicate(criteriaBuilder);
3136
}
3237

0 commit comments

Comments
 (0)