Created
January 31, 2019 14:23
-
-
Save iamitshri/ee58df5f6f48a2ebb0f54b8884f38c4f to your computer and use it in GitHub Desktop.
Fetch data using Spring data paging
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int page = 0; | |
Page<Entity> pages = repo.findAll(PageRequest.of(page, 1000)); | |
while(!pages.isLast()) { | |
List<Entity> content = pages.getContent(); | |
// Do your thing with the content | |
Pageable pageable = pages.nextPageable(); | |
pages = submissionRepo.findAll(pageable); | |
log.info("page number {} size:{}, offset:{}",pageable.getPageNumber(),pageable.getPageSize(),pageable.getOffset()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment