【发布时间】:2020-10-18 09:44:47
【问题描述】:
AI_DpEntriesRepository.java
public interface AI_DpEntriesRepository extends PagingAndSortingRepository<AI_DpEntries, Long>{
@Query(value = "select a.*,m.description,m.name from AI_DPENTRIES a,"
+ "MEDICALHIERARCHY m where PAGEID in (select pageid from PAGES where caseid=8960)"
+ " and a.HID=m.ID",nativeQuery = true)
Page<AI_DpEntries> getLabAIDpEntries(Pageable pageable);
}
AIDpEntryServiceImpl.java
public class AIDpEntryServiceImpl implements AIDpEntryService{
@Autowired
private AI_DpEntriesRepository aiDpEntryRepository;
@Override
@Cacheable("labdpentries")
public Page<AI_DpEntries> getAIDpEntries(int page,int size) {
Pageable pageRequest = PageRequest.of(page, 5);
Page<AI_DpEntries> pageResult = aiDpEntryRepository.getLabAIDpEntries(pageRequest);
List<AI_DpEntries> dpEntries = pageResult.getContent().stream().collect(Collectors.toList());
return new PageImpl<>(dpEntries, pageRequest, pageResult.getTotalElements());
//return aiDpEntryRepository.getLabAIDpEntries();
}
}
获取 java.sql.SQLSyntaxErrorException: ORA-00904: "A": 无效标识符 从存储库调用本身。我究竟做错了什么?如果我将 size 参数值作为 Integer.MAX_VALUE 传递,它将当前一次返回所有记录。但我的要求是每页获得 5 条记录
【问题讨论】:
-
请发布完整的堆栈跟踪(格式化为代码)和您的 JPA 实现实际尝试执行的日志中的 SQL 语句。
-
已解决:此处需要计数查询以及存储库中的查询,它应该返回与查询方法返回的行相同的计数。
-
请发布完整的答案,以便其他人可以从中受益。或者,请删除问题。
-
@JensSchauder 作为答案发布
标签: java spring spring-boot spring-data-jpa pagination