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
NOTE: Copies of this document may be made for your own use and for distribution to others, provided that you do not charge any fee for such copies and further provided that each copy contains this Copyright Notice, whether distributed in print or electronically.
<4> Valid `Sort` expression pointing to aliased function.
528
530
====
529
531
532
+
[[jpa.query-methods.scroll]]
533
+
=== Scrolling large Query Results
534
+
535
+
When working with large data sets, <<repositories.scrolling,scrolling>> can help to process those results efficiently without loading all results into memory.
536
+
537
+
Spring Data JPA supports offset- and keyset-based scrolling.
538
+
A variant of offset scrolling provided through <<repositories.paging-and-sorting,Paging>>.
539
+
540
+
Keyset-based scrolling avoids https://use-the-index-luke.com/no-offset[the shortcomings of offset-based result retrieval by leveraging database indexes].
541
+
However, keyset-based results should avoid `null` values as these do not work well with sorting.
542
+
543
+
In contrast to `Page<T>`, the Scroll API returning `Window<T>` is much more lightweight and flexible.
544
+
545
+
You can use the Scroll API with query methods, <<query-by-example.running,Query-by-Example>>, and <<core.extensions.querydsl,Querydsl>>.
546
+
547
+
NOTE: Scrolling with String-based query methods is not yet supported.
548
+
Scrolling is also not supported using stored `@Procedure` query methods.
549
+
530
550
[[jpa.named-parameters]]
531
551
=== Using Named Parameters
532
552
533
-
By default, Spring Data JPA uses position-based parameter binding, as described in all the preceding examples. This makes query methods a little error-prone when refactoring regarding the parameter position. To solve this issue, you can use `@Param` annotation to give a method parameter a concrete name and bind the name in the query, as shown in the following example:
553
+
By default, Spring Data JPA uses position-based parameter binding, as described in all the preceding examples.
554
+
This makes query methods a little error-prone when refactoring regarding the parameter position.
555
+
To solve this issue, you can use `@Param` annotation to give a method parameter a concrete name and bind the name in the query, as shown in the following example:
534
556
535
557
.Using named parameters
536
558
====
537
-
[source,java]
559
+
[source,java]
538
560
----
539
561
public interface UserRepository extends JpaRepository<User, Long> {
0 commit comments