Provide an option for a simple wrapper count query #3706
Labels
for: team-attention
An issue we need to discuss as a team to make progress
status: waiting-for-triage
An issue we've not yet triaged
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: