您好,登錄后才能下訂單哦!
CustomerRepository.java
@Query(nativeQuery = true, value = "select * from adm_sys_customer ORDER BY ?#{#pageable}", countQuery = "select count(*) from adm_sys_customer") Page<Customer> findAllByPageable(Pageable pageable);
CustomerServiceImpl.java
//調用自定義sql Page<Customer> pageObjectList = customerRepos.findAllByPageable(pageService.getPageable(1, 1, null));
ORDER BY ?#{#pageable} 必須加,否則報錯:
Caused by: org.springframework.data.jpa.repository.query.InvalidJpaQueryMethodException:
Cannot use native queries with dynamic sorting and/or pagination in ...
參考:https://www.cnblogs.com/jiangxiaoyaoblog/p/5635152.html
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。