You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The results of the two queries are different, adding a distinct before the count does not change the result, while adding it inside the count can change the result
Affects: 1.10.5 (Hopper SR5)
1 votes, 1 watchers
The text was updated successfully, but these errors were encountered:
This issue is definitely valid. It reveals that JpaCountQueryCreator needs its own patch to handle boolean distinct than how JpaQueryCreator does.
A small patch can fix this from being select distinct count(distinct ...) ... to select count(distinct ...)....
However, this is incomplete, since countDistinctByXXX() will still render select count(distinct u.id) ..., which has no net benefit. So I went and captured this bigger issue of how Spring Data JPA deals with DISTINCT operations in #2525.
When performing a count operation, we are using countDistinct from JPA, and hence, don't need the JpaQueryCreator applying distinct outside the whole thing.
Also added some details in the ref docs to help guide users on writing proper distinct-based queries.
See #1380.
When performing a count operation, we are using countDistinct from JPA, and hence, don't need the JpaQueryCreator applying distinct outside the whole thing.
Also added some details in the ref docs to help guide users on writing proper distinct-based queries.
See #1380.
Anthony opened DATAJPA-1036 and commented
When we use a count query with a distinct:
The generated sql is:
instead of
The results of the two queries are different, adding a distinct before the count does not change the result, while adding it inside the count can change the result
Affects: 1.10.5 (Hopper SR5)
1 votes, 1 watchers
The text was updated successfully, but these errors were encountered: