Pagination support

It is important to note that the Spring Data team intentionally omitted pagination support as the implementation used in synchronous repositories does not fit the reactive paradigm. To calculate the parameters of the next page, we need to know the number of returned records for the previous result. Also, to calculate the total amount of pages using that approach, we need to query for the total amount of records. Both aspects do not fit the reactive non-blocking paradigm. Additionally, querying the database to count all rows is rather expensive, and increases the lag before actual data processing. However, it is still possible to fetch chunks of data by passing the Pageable object to the repository as follows:

public interface ReactiveBookRepository
    extends ReactiveSortingRepository<Book, Long> {

    Flux<Book> findByAuthor(String author, Pageable pageable);
}

So, now we may request the second page of the result (note, the indexes start from 0), where each page contains five elements:

Flux<Book> result = reactiveBookRepository
    .findByAuthor('Andy Weir', PageRequest.of(1, 5));
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.189.171.153