Hi, There is a bug with Hibernate 5.4.5 and higher. New spring boot 2.2.0 and hibernate 5.4.6 paging is not working properly for repositories. For this part of code in spring boot:
----
* protected <S extends T> TypedQuery<Long> getCountQuery(@Nullable Specification<S> spec, Class<S> domainClass) \{ * * CriteriaBuilder builder = this.em.getCriteriaBuilder(); * * CriteriaQuery<Long> query = builder.createQuery(Long.class); * * Root<S> root = this.applySpecificationToCriteria(spec, domainClass, query); * * if (query.isDistinct()) \{ * * query.select(builder.countDistinct(root)); * * } else \{ * * query.select(builder.count(root)); * * } *
* query.orderBy(Collections.emptyList()); * * return this.em.createQuery(query); * * } *
----
the count query is not taking into account inherited entities and the query look like below:
----
* select count(keycloakfe0_.id) as col_0_0_ * * from keycloak_fed_mapper_ldap keycloakfe0_ * * inner join keycloak_federation keycloakfe1_ on keycloakfe0_1_.id_federation=keycloakfe1_.id * * where keycloakfe1_.environment=? *
----
I've verified all version since 5.4.0 to 5.4.8. Before version 5.4.5 query was ok. Query for version 5.4.4 is:
----
* select count(keycloakfe0_.id) as col_0_0_ * * from keycloak_fed_mapper_ldap keycloakfe0_ * * inner join keycloak_fed_mapper keycloakfe0_1_ on keycloakfe0_.id=keycloakfe0_1_.id * * inner join keycloak_federation keycloakfe1_ on keycloakfe0_1_.id_federation=keycloakfe1_.id * * where keycloakfe1_.environment=? *
----
The issue it that this bug ha a big impact on spring repositories abstraction with paging mechanism. I assue it may be related with this feature in 5.4.5 release
[https://hibernate.atlassian.net/browse/HHH-12993|https://hibernate.atlassian.net/browse/HHH-12993]
If more details required please let me know.
{noformat}{noformat}
|
|