Closed mp911de closed 1 week ago
It is possible to use String-based queries. We should consider how to inject Keyset-pagination predicates and introduce joins for sort by fields that work for part tree queries and JPQL queries using ideally the same mechanism.
Is this why FilterDef broke somewhere between Spring Boot 2.1 and 2.5? See #2565
If queries are rendered to JPQL/HQL again, then can they be created through EntityManager, so that those of us who unwrap Session and enable filters will be able to use @FilterDefs
again?
If queries are rendered to JPQL/HQL again,
We've been using CriteriaQuery for derived queries and SimpleJpaRepository
implementations since the inception of Spring Data JPA.
Why does JPQL queries perform better than Criteria Queries? Parsing JPQL into SQM seems more heavy than mapping CriteriaQuery to SQM, maybe it should be improved at Hibernate side, or something going wrong at Spring Data JPA side.
Why does JPQL queries perform better than Criteria Queries?
Because Hibernate seems to cache the parsed HQL query.
We should explore how we could switch from Criteria Queries to JPQL queries as Hibernate has a much better efficiency running String-based queries:
We would need to build our own
JpqlQueryBuilder
that mimicsCriteriaBuilder
in terms of expressions, predicates and automated inclusion of joins.Collection of related tickets: