![](/img/trans.png)
[英]How is my id being generated with JPA using Hibernate with the Oracle 10g dialect?
[英]How to get paginated result in Spring JPA repository using Oracle 10g
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 條記錄
此處的解決方案 - 需要計數查詢以及將返回相同編號的本機查詢。 由本機查詢返回的行數(從問題中查詢的 PS-Minor 更改)
@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);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.