SpringData JPA @Query分页查询 Cannot use native queries with dynamic sorting and/or pagination in method
2017-07-21 09:47
741 查看
异常信息:
执行sql
修改成:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'newsDao': Invocation of init method failed; nested exception is org.springframework.data.jpa.repository.query.InvalidJpaQueryMethodException: Cannot use native queries with dynamic sorting and/or pagination in method public abstract org.springframework.data.domain.Page com.example.demo.repository.NewsDao.findByTitle(java.lang.String,org.springframework.data.domain.Pageable)
执行sql
//分页 nativeQuery=true 表示采用原生SQL语句进行操作 @Query(value = "select id,title,content from news where title =?1", countQuery = "select count(*) from news where title =?1", nativeQuery = true) Page<News> findByTitle(String title, Pageable pageable);
修改成:
//分页 nativeQuery=true 表示采用原生SQL语句进行操作 @Query(value = "select id,title,content from News n where n.title =?1", countQuery = "select count(*) from News n where n.title =?1", nativeQuery = false) Page<News> findByTitle(String title, Pageable pageable);
相关文章推荐
- spring.data.jpa.query :Cannot use native queries with dynamic sorting and/or pagination in method
- TRIGGERS :Cannot use text, ntext, or image columns in the 'inserted' and ' deleted' tables.
- The method or function that was called cannot be used in the manner requested.
- Cannot start session without errors, please check errors given in your PHP and/or webserver log file
- Use "OR" in SQL with caution
- How to use a 32bit Oracle11_g client in 64 win system and not conflict with sqldeveloper 64 bit tool
- Apache Address already in use: make_sock: could not bind to port 80 or 443 error and solution
- Method and system for implementing mandatory file access control in native discretionary access control environments
- Compiling and Running a Java Program with a Native Method
- eclipse-- workspace in use or cannot be created, choose a different one.
- Workspace in use or cannot be created, choose a different one.–解决办法
- maven使用jstl表达式和The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application解决
- How to create aligned partitions in Linux for use with NetApp LUNs, VMDKs, VHDs and other virtual di
- Workspace in use or cannot be created, choose a different one.
- Use Named Pipes and Shared Memory for inter process communication with a child process or two
- [Yii Framework] How to run cron job (or use command) in the server with yii framework
- Workspace in use or cannot be created, choose a different one.错误的解决办法
- Workspace in use or cannot be created, choose a different one.--错误解决办法
- Workspace in use or cannot be created, choose a different one.--错误解决办法
- Cannot start session without errors, please check errors given in your PHP and/or webserver log