我正在尝试进行存储库调用,该调用将通过扩展 JpaRepository 从我的数据库(Page< WorklistMst>)中获取 WorkListMst Beans 列表,但它给了我以下结果:
Page 1 of 0 containing UNKNOWN instances
我的存储库是这样的:
Page<WorklistMstBean> findByProcessId(Integer processId, Pageable pageable);
此外,我检查了日志中生成的休眠查询,它看起来完全正确,我也执行了它,它给了我正确的结果。
Pageable 生成如下:
public Pageable validatePageable(Integer pageNo, Integer size, String sortBy, String sortOrder) {
Pageable pageable = null;
if(ProcessData.isValid(pageNo) && ProcessData.isValid(size)) {
if (pageNo < 1 || size < 1) {
LOGGER.error("Invalid pageable params.");
throw new InvalidArgumentException("Invalid pageable params.");
}
pageable = new PageRequest(pageNo-1, size, sort(sortOrder, sortBy));
}
return pageable;
}
private Sort sort(String sortOrder, String sortBy) {
Sort sort = null;
Sort.Direction direction;
if(ProcessData.isValid(sortBy)) {
if("asc".equalsIgnoreCase(sortOrder)) {
direction = Sort.Direction.ASC;
} else if("desc".equalsIgnoreCase(sortOrder)){
direction = Sort.Direction.DESC;
} else {
direction = Sort.Direction.ASC;
}
sort = new Sort(direction, sortBy);
}
return sort;
}
}
任何帮助表示赞赏。