From a9e7456ca580bb47c1eb15973af6c832e81f4d2f Mon Sep 17 00:00:00 2001 From: Romuald Lemesle Date: Wed, 25 Sep 2024 10:41:25 +0200 Subject: [PATCH] [backend] Fix wrong count for pagination --- .../main/java/io/openbas/database/criteria/GenericCriteria.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openbas-model/src/main/java/io/openbas/database/criteria/GenericCriteria.java b/openbas-model/src/main/java/io/openbas/database/criteria/GenericCriteria.java index 5235aca3f9..0c5c98dd82 100644 --- a/openbas-model/src/main/java/io/openbas/database/criteria/GenericCriteria.java +++ b/openbas-model/src/main/java/io/openbas/database/criteria/GenericCriteria.java @@ -21,7 +21,7 @@ public static Long countQuery( Specification specification) { CriteriaQuery countQuery = cb.createQuery(Long.class); Root countRoot = countQuery.from(entityClass); - countQuery.select(cb.count(countRoot)); + countQuery.select(cb.countDistinct(countRoot)); if (specification != null) { Predicate predicate = specification.toPredicate(countRoot, countQuery, cb); if (predicate != null) {