Spring Data Slice: difference between getSize() and getNumberOfElements()

jhyot :

What is the difference between getSize() and getNumberOfElements in the Spring Data class org.springframework.data.domain.Slice?

The Javadoc does not offer too much help here.

Jakub Ch. :

getSize() returns the capacity of the Slice.

getNumberOfElements() how many elements does the Slice contains.

For example: You want Page of data from PagingAndSortingRepository. You can call method like repo.findAll(new PageRequest(0,30)) what means you request for first page of data which contains 30 entities at most. Assuming that there are only 10 entities in database you receive a Page where size is 30 and numberOfElements is 10.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=454489&siteId=1