kkaun
kkaun

Reputation: 603

Way to ensure that current page is the last one with Spring Data Paging

I'm trying to optimize the number of aggregation requests for my service using Spring Data.

Is there a legit way to find out that the page returned by repository method like this:

List<Place> findByVisitorsUid(String uid, Pageable pageable);

requested with PageRequest like this:

Pageable pageable = new PageRequest(currentPage, pageSize);

is actually the last page?

In other words, is there a way to ensure that there are no more data chunks to be returned with current page request params like fixed page size etc., except making extra repository request with incremented page index?

Thanks in advance.

Upvotes: 1

Views: 3061

Answers (1)

kkaun
kkaun

Reputation: 603

Thanks to manish I'm pretty sure now that if you're pursuing the goal described in question than repository method should return Page instead of List (though it's not necessary for simple paging functionality).

Upvotes: 1

Related Questions