spring-data-jpa - 我真的需要在原生 @Query 中使用 countQuery 进行分页吗?
问题描述
根据参考,countQuery
本机查询分页需要(至少有一个示例)。但根据我的测试(Spring Boot 2.4.5),@Query 分页在没有countQuery
此类查询的情况下工作:
public interface ARepository extends JpaRepository<A, Long>{
@Query(value = "select * from a", nativeQuery = true)
Page<A> findAllANative(Pageable pageable);
@Query(value = "select count(a.id) as aCount, category.name as
categoryName " +
"from a " +
"join category on a.category_id=category.id " +
"group by category.name",
nativeQuery = true)
List<CountView> findACountByCategoryNative(Pageable pageable);
}
如您所见,没有countQuery
,它们有效。
分页是否仅适用于这些特定查询,或者我可以countQuery
在所有情况下省略?
解决方案
推荐阅读
- javascript - 接受时的 HTML/Javascript 输入图像触发操作
- linux - RT 进程如何为 CFS 进程释放 CPU,并在没有准备好的 CFS 进程时将其取回
- javascript - 在数组中搜索至少 1 个匹配项并返回 true
- angular - 升级到 Angular 8:在 tsconfig.json 中将目标更改为“es2015”会导致 polyfills-2015 出错
- makefile - 如何在 Make 中为多个模式规则共享相同的配方?
- angular - Angular @Input() 可能有也可能没有这个值
- python - 如何实时实现颜色一致的不闪烁深度图?
- r - 在 Clara (Clarans) 中确定样本大小
- javascript - 如何在 PHP 中按下后退按钮时停止显示警报框?
- javascript - 迭代和存储等于自身的对象