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/asciidoc/repositories-paging-sorting.adoc
+32-6
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,12 @@
1
1
[[repositories.special-parameters]]
2
-
=== Paging, Iterating Large Results, Sorting
2
+
=== Paging, Iterating Large Results, Sorting & Limiting
3
3
4
4
To handle parameters in your query, define method parameters as already seen in the preceding examples.
5
-
Besides that, the infrastructure recognizes certain specific types like `Pageable`and `Sort`, to apply paginationand sorting to your queries dynamically.
5
+
Besides that, the infrastructure recognizes certain specific types like `Pageable`, `Sort` and `Limit`, to apply pagination, sorting and limiting to your queries dynamically.
6
6
The following example demonstrates these features:
7
7
8
8
ifdef::feature-scroll[]
9
-
.Using `Pageable`, `Slice`, `ScrollPosition`, and `Sort` in query methods
9
+
.Using `Pageable`, `Slice`, `ScrollPosition`, `Sort` and `Limit` in query methods
IMPORTANT: APIs taking `Sort`and `Pageable` expect non-`null` values to be handed into methods.
43
-
If you do not want to apply any sorting or pagination, use `Sort.unsorted()` and `Pageable.unpaged()`.
46
+
IMPORTANT: APIs taking `Sort`, `Pageable` and `Limit` expect non-`null` values to be handed into methods.
47
+
If you do not want to apply any sorting or pagination, use `Sort.unsorted()`, `Pageable.unpaged()` and `Limit.unlimited()`.
44
48
45
49
The first method lets you pass an `org.springframework.data.domain.Pageable` instance to the query method to dynamically add paging to your statically defined query.
46
50
A `Page` knows about the total number of elements and pages available.
@@ -57,6 +61,28 @@ Rather, it restricts the query to look up only the given range of entities.
57
61
NOTE: To find out how many pages you get for an entire query, you have to trigger an additional count query.
58
62
By default, this query is derived from the query you actually trigger.
59
63
64
+
[IMPORTANT]
65
+
====
66
+
Special parameters may only be used once within a query method. +
67
+
Some of the special parameters described above are mutually exclusive.
68
+
Please consider the following list of invalid parameter combinations.
69
+
70
+
|===
71
+
| Parameters | Example | Reason
72
+
73
+
| `Pageable` & `Sort`
74
+
| `findBy...(Pageable page, Sort sort)`
75
+
| `Pageable` already defines `Sort`
76
+
77
+
| `Pageable` & `Limit`
78
+
| `findBy...(Pageable page, Limit limit)`
79
+
| `Pageable` already defines a limit.
80
+
81
+
|===
82
+
83
+
The `Top` keyword used to limit results can be used to along with `Pageable` whereas `Top` defines the total maximum of results, whereas the Pageable parameter may reduce this this number.
0 commit comments