-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide an option for a simple wrapper count query #3706
Comments
Paging @schauder. I am not sure how much trouble we create when using subqueries as Spring Data JPA is used with all sorts of database systems, even those that pretend to support SQL, although their backend is a NoSQL database. Using top-level count queries is less invasive. Our own query rewriter is based on Rexex and has limitations when it comes to more complex queries. We recommend using the JSqlParser-based rewriter (see #3707) or manually-declared queries as alternatives. |
Or introduce |
We're exploring a different approach that lets folks select their |
We do not plan on providing more SPI than will be available via #3527. |
I have many complex native queries where Spring Data can't figure out count queries out of the box. Think of anything involving
SELECT DISTINCT
. My queries return correct results, but the total count is incorrect when using pagination. The total result is 300 records, but the count returns 650 due to duplicated records without DISTINCT, which the count query creator strips out.An obvious solution is to provide a custom count query. It works. But it also makes code hardly maintainable because I have to duplicate page-sized queries and just make them double:
value
andcountQuery
. I suggest a simple wrapper option that will take avalue
and create a count query likeIt won't solve all issues for everyone, but at least it will allow users to not repeat themselves for 100x of queries.
The text was updated successfully, but these errors were encountered: