spring-projects / spring-data-jpa

Simplifies the development of creating a JPA-based data access layer.
https://spring.io/projects/spring-data-jpa/
Apache License 2.0
3.01k stars 1.42k forks source link

Undeprecate QueryUtils createCountQueryFor, or make DeclaredQuery public [DATAJPA-1670] #1970

Closed spring-projects-issues closed 4 years ago

spring-projects-issues commented 4 years ago

Jean-Baptiste Nizet opened DATAJPA-1670 and commented

Sometimes, a static JPQL query isn't sufficient, but using the criteria API or QueryDSL is much harder than simply compose a JPQL query dynamically.

It would be nice however to be able to derive a count query automatically for such JPQL queries. It's currently possible using QueryUtils.createCountQueryFor(), but this metod is deprecated. And its replacement (DeclaredQuery.deriveCountQuery) is not usable because DeclaredQuery is not a public interface.

In general, it would be nice if there was an easy public API, usable from custom repository implementations, that provided the same support as the Query annotation to execute paged queries:

It's not as easy as it could be to do that now, and relies on a deprecated method with no public replacement for the count query derivation

 


Affects: 2.2.4 (Moore SR4)

spring-projects-issues commented 4 years ago

Jens Schauder commented

In order to do this properly we would need to create a completely new abstraction which we right now are not able to support.

I'm therefore closing this issue.

This is based on our impression that the use case is very special and only few users would benefit from this. If you have a use case that has broad applicability this might change our mind