Skip to content

Commit

Permalink
Merge pull request jakartaee#748 from jakartaee/pagination-sample
Browse files Browse the repository at this point in the history
Enhance documentation readme file
  • Loading branch information
otaviojava authored May 31, 2024
2 parents 6a4da7d + 9333bfa commit 870aa51
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,26 @@ Whether you use built-in repository interfaces or create custom repositories, Ja

==== Pagination

Jakarta Data also supports parameters to define pagination and sorting.
Jakarta Data supports two types of Pagination: offset and cursor-based Pagination.

- **Offset Pagination**: Offset-based pagination computes pages relative to a positional offset from the beginning of the dataset given the requested page number and page size.

- **Cursor-based Pagination**: Cursor-based Pagination aims to reduce missed and duplicate results across pages by querying relative to the observed values of entity properties that constitute the sorting criteria. This method uses a cursor, a pointer to a specific position in the dataset, to navigate the dataset.

Example code using both pagination methods:

[source,java]
----
@Repository
public interface CarRepository extends BasicRepository<Car, Long> {
Page<Car> findByTypeOrderByName(CarType type, PageRequest pageRequest);
@Find
@OrderBy(_Car.NAME)
@OrderBy(_Car.VIN)
CursoredPage<Car> type(CarType type, PageRequest pageRequest);
}
----

Expand Down

0 comments on commit 870aa51

Please sign in to comment.