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
Copy file name to clipboardExpand all lines: src/main/antora/modules/ROOT/pages/jpa/query-methods.adoc
+3-3Lines changed: 3 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -74,7 +74,7 @@ NOTE: `In` and `NotIn` also take any subclass of `Collection` as a parameter as
74
74
====
75
75
`DISTINCT` can be tricky and not always producing the results you expect.
76
76
For example, `select distinct u from User u` will produce a complete different result than `select distinct u.lastname from User u`.
77
-
In the first case, since you are including `User.id`, nothing will duplicated, hence you'll get the whole table, and it would be of `User` objects.
77
+
In the first case, since you are including `User.id`, nothing will be duplicated, hence you'll get the whole table, and it would be of `User` objects.
78
78
79
79
However, that latter query would narrow the focus to just `User.lastname` and find all unique last names for that table.
80
80
This would also yield a `List<String>` result set instead of a `List<User>` result set.
@@ -83,7 +83,7 @@ This would also yield a `List<String>` result set instead of a `List<User>` resu
83
83
`countDistinctByLastname(String lastname)` can also produce unexpected results.
84
84
Spring Data JPA will derive `select count(distinct u.id) from User u where u.lastname = ?1`.
85
85
Again, since `u.id` won't hit any duplicates, this query will count up all the users that had the binding last name.
86
-
Which would the same as `countByLastname(String lastname)`!
86
+
Which would be the same as `countByLastname(String lastname)`!
87
87
88
88
What is the point of this query anyway? To find the number of people with a given last name? To find the number of _distinct_ people with that binding last name?
89
89
To find the number of _distinct last names_? (That last one is an entirely different query!)
@@ -394,7 +394,7 @@ You have multiple options to consume large query results:
394
394
You have learned in the previous chapter about `Pageable` and `PageRequest`.
0 commit comments