[英]Pagination in cassandra with Spring-data
I'm trying to get paginated results in cassandra using springboot, but I'm not getting desired results. 我正在尝试使用springboot在cassandra中获得分页结果,但我没有得到理想的结果。 Here is my code.
这是我的代码。
Slice<User> usersByNameSlice =
userRepository.findAll(CassandraPageRequest.first(10));
while (usersByNameSlice .hasNext()) {
//.. process
usersByNameSlice = userRepository.findAll(usersByNameSlice.nextPageable());
}
I have around 35 users. 我有大约35个用户。 This while loop works 3 times covering 30 users, but it comes out of the while loop after 30. How to solve this problem?
这个while循环工作3次,覆盖30个用户,但它在30之后的while循环中出现。如何解决这个问题?
I think that you need to change the condition of the while
loop to usersByNameSlice.hasContent()
to check if there is content in the slice at all. 我认为您需要将
while
循环的条件更改为usersByNameSlice.hasContent()
以检查切片中是否有内容。
(Or maybe to combine it with check isPaged()
even - because nextPageable
on the last page will return unpaged state). (或者甚至可以将它与check
isPaged()
结合使用 - 因为最后一页上的nextPageable
将返回未处理状态)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.