我想知道是否有简单的方法(或至少计划添加该功能)如何返回 Slice将规范传递给 JpaSpecificationExecutor .findAll(Specification spec,
Pageable pageable) 时没有计数查询
所以我想做这样的事情:
Slice<MessageViewEntity> messageViewEntities =
messageViewRepository.findAll(
messageViewRepository.withSearchSpecifications(language, categoryId, messageKey, longText),
new PageRequest(page, size)
);
不会执行 count 查询的地方。
我找到了 this question已经快 2 岁了,但在当前版本 10.1.2 中,我看不到如何执行此操作的方法/方式。
谢谢
最佳答案
可以办到。看这里:
https://gist.github.com/tcollins/0ebd1dfa78028ecdef0b
基本上你需要:
关于java - 没有计数的具有规范的 spring-data 切片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38369907/