小编Chr*_*ang的帖子

当规范和Pageable一起使用时如何禁用计数?

JpaSpecificationExecutor附带的方法是不够的,它们都没有给我我想要的东西:

Page<T> findAll(Specification<T> spec, Pageable pageable)

List<T> findAll(Specification<T> spec)

List<T> findAll(Specification<T> spec, Sort sort)
Run Code Online (Sandbox Code Playgroud)

第一种方法执行分页查询和计数查询.接下来的2个根本不执行分页.我需要的是以下之一:

Slice<T> findAll(Specification<T> spec, Pageable pageable)

List<T> findAll(Specification<T> spec, Pageable pageable)
Run Code Online (Sandbox Code Playgroud)

通过不扩展JpaSpecificationExecutor,我能够执行两个查询,但计数查询也是如此.在我的情况下,必须避免计数查询,因为它非常昂贵.问题是如何?

spring spring-data spring-data-jpa

13
推荐指数
2
解决办法
8741
查看次数

标签 统计

spring ×1

spring-data ×1

spring-data-jpa ×1