Skip to content

Commit 053cbef

Browse files
committed
Add documentation.
1 parent 60f2427 commit 053cbef

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

src/main/asciidoc/index.adoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ Oliver Gierke; Thomas Darimont; Christoph Strobl; Mark Paluch; Jay Bryant; Greg
55
ifdef::backend-epub3[:front-cover-image: image:epub-cover.png[Front Cover,1050,1600]]
66
:spring-data-commons-docs: ../../../../spring-data-commons/src/main/asciidoc
77
:spring-framework-docs: https://docs.spring.io/spring-framework/docs/{springVersion}/spring-framework-reference/
8+
:feature-scroll: true
89

9-
(C) 2008-2022 The original authors.
10+
(C) 2008-2023 The original authors.
1011

1112
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.
1213

src/main/asciidoc/jpa.adoc

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -521,20 +521,42 @@ repo.findByAndSort("stark", Sort.by("LENGTH(firstname)")); <2>
521521
repo.findByAndSort("targaryen", JpaSort.unsafe("LENGTH(firstname)")); <3>
522522
repo.findByAsArrayAndSort("bolton", Sort.by("fn_len")); <4>
523523
----
524+
524525
<1> Valid `Sort` expression pointing to property in domain model.
525-
<2> Invalid `Sort` containing function call. Throws Exception.
526+
<2> Invalid `Sort` containing function call.
527+
Throws Exception.
526528
<3> Valid `Sort` containing explicitly _unsafe_ `Order`.
527529
<4> Valid `Sort` expression pointing to aliased function.
528530
====
529531

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+
530550
[[jpa.named-parameters]]
531551
=== Using Named Parameters
532552

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:
534556

535557
.Using named parameters
536558
====
537-
[source, java]
559+
[source,java]
538560
----
539561
public interface UserRepository extends JpaRepository<User, Long> {
540562

0 commit comments

Comments
 (0)