Example usage for org.springframework.data.repository PagingAndSortingRepository findAll

List of usage examples for org.springframework.data.repository PagingAndSortingRepository findAll

Introduction

In this page you can find the example usage for org.springframework.data.repository PagingAndSortingRepository findAll.

Prototype

Page<T> findAll(Pageable pageable);

Source Link

Document

Returns a Page of entities meeting the paging restriction provided in the Pageable object.

Usage

From source file:org.openlmis.fulfillment.AuditLogInitializer.java

private void createSnapshots(PagingAndSortingRepository<?, ?> repository) {
    Pageable pageable = new PageRequest(DEFAULT_PAGE_NUMBER, 2000);

    while (true) {
        Page<?> page = repository.findAll(pageable);

        if (!page.hasContent()) {
            break;
        }/*from  w  ww  .j a v a2  s .c  o  m*/

        page.forEach(this::createSnapshot);

        pageable = pageable.next();
    }
}