0

I am making an application in which I have used spring-data-jpa. I have used PagingAndSortingRepository and its working fine. I can see all the records returned as pages.

I have one scenario where I need to retrieve all records for a single day. I need to fetch all records using single request. I found we can set Page size as Integer.MAX_VALUE. But I read maximum records that a Page can have is 1000. More info here.

How should I configure the Pageable object to fetch all records in single request.

Derrick
  • 3,669
  • 5
  • 35
  • 50
Kuldeep Singh
  • 1,214
  • 4
  • 18
  • 45

1 Answers1

1

Updated answer (2019-02-26)

The best solution is probably this one now:

https://stackoverflow.com/a/53924025/7709086

That is:

var pagedEntities = repo.findAll(Pageable.unpaged());

Old answer

Do not pass it, aka findAll() instead of findAll(Pageable pageable).

If returning a Page (and not a List) is mandatory, you can wrap it afterwards:

var pagedEntities = new PageImpl(repo.findAll());
kagmole
  • 2,005
  • 2
  • 12
  • 27