I am using Spring data neo4j (version 5.1.9.Release) and spring-data-commons (2.1.9.Release).
In order to paginate my results, I am using
Page<Part> fetchPartsById(@Param("Id") String Id, Pageable pageable);
I call the method
fetchPartsById as follows -
Page<Part> results = fetchPartsById("1", PageRequest(0, 5))
I was expecting that as I am passing size of 5,
results.getContent() should return a list of only 5 elements. However, the list contains all the 40 elements. This defeats the purpose of pagination.
I also tried using
Slice instead of
Slice<Part> fetchPartsById(@Param("Id") String Id, Pageable pageable);
Slice<Part> results = fetchPartsById("1", PageRequest(0, 5))
Slice does return only the requested 5 elements. However, the problem with using
Slice is that I am not aware how to get the next set of results. I tried using
results.nextPageable(). This causes the page number to go to next page however it returns no result the second time around. Looks like the results are only on page number 0.
Does anybody know how to use Pagination with Spring data neo4j.
Note : These results are fed to an UI. Hence, the parameters to the
PageRequest.of() are driven by the UI. I want to load initial 5 elements from db and on next request next 5 should be loaded.