Java 如何使用Oracle 10g在Spring JPA存储库中获得分页结果

Java 如何使用Oracle 10g在Spring JPA存储库中获得分页结果,java,spring,spring-boot,spring-data-jpa,pagination,Java,Spring,Spring Boot,Spring Data Jpa,Pagination,AI_DpEntriesRepository.java AIDpEntryServiceImpl.java 获取java.sql.SQLSyntaxErrorException:ORA-00904:A:无效标识符 从存储库调用它自己。我做错了什么?如果我将size参数值作为Integer.MAX_值传递,它将在当前一次返回所有记录。但我的要求是每页获得5条记录这里的解决方案-需要使用计数查询和本机查询,本机查询返回的行数与本机查询返回的行数相同 @Repository public interf

AI_DpEntriesRepository.java

AIDpEntryServiceImpl.java

获取java.sql.SQLSyntaxErrorException:ORA-00904:A:无效标识符
从存储库调用它自己。我做错了什么?如果我将size参数值作为Integer.MAX_值传递,它将在当前一次返回所有记录。但我的要求是每页获得5条记录

这里的解决方案-需要使用计数查询和本机查询,本机查询返回的行数与本机查询返回的行数相同

@Repository
public interface AI_DpEntriesRepository extends JpaRepository<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 And (a.REVIEW_IND != 'D' OR a.REVIEW_IND IS NULL),
countQuery = "select * from AI_DPENTRIES where PAGEID in (select pageid from PAGES where caseid=8960) and (REVIEW_IND != 'D' OR REVIEW_IND IS NULL)",nativeQuery = true)

public Page<AI_DpEntries> getLabAIDpEntries(Pageable pageable);

}

请发布格式为代码的完整堆栈跟踪以及JPA实现实际尝试执行的日志中的SQL语句。解决方法:此处需要计数查询以及存储库中的查询,它应该返回与查询方法返回的行相同的计数。请发布完整答案,以便其他人可以从中受益。或者,请删除该问题。@Jenschauder作为答案发布
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();
    }

}
@Repository
public interface AI_DpEntriesRepository extends JpaRepository<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 And (a.REVIEW_IND != 'D' OR a.REVIEW_IND IS NULL),
countQuery = "select * from AI_DPENTRIES where PAGEID in (select pageid from PAGES where caseid=8960) and (REVIEW_IND != 'D' OR REVIEW_IND IS NULL)",nativeQuery = true)

public Page<AI_DpEntries> getLabAIDpEntries(Pageable pageable);

}