springboot jpa 分页查询页数错误

我在写一个数据查询的接口时,使用jpa pageable
 Page<BuddhistCommonSense> buddhistCommonSenses =
buddhistCommonSenseRepository.findAll((root, criteriaQuery, criteriaBuilder) -> {
root = criteriaQuery.from(BuddhistCommonSense.class);
Path<Integer> enablePath = root.get("enable");
return criteriaBuilder.and(criteriaBuilder.equal(enablePath,enable));
},pageable);
model.addAttribute("page",page);
model.addAttribute("enable",enable);
model.addAttribute("list",buddhistCommonSenses.getContent());
model.addAttribute("totalPage",buddhistCommonSenses.getTotalPages()); 得到的总页数每次都是23232
已邀请:

xiaoxiao

赞同来自:

而且enable作为判断参数,没有效果,jpa是刚学,请大牛解释一下

xiaoxiao

赞同来自:

spring.jpa.show_sql=true 


添加了这段代码后 看到sql语句 终于一目了然了
select count(buddhistco0_.id) as col_0_0_ from buddhist_common_sense buddhistco0_ cross join buddhist_common_sense buddhistco1_ where buddhistco1_.enable=1
发布不知道为撒他要价格cross in 

要回复问题请先登录注册