PageHelper 空指針異常


開發環境:

springBoot、myBatis、sqlServer、PageHelper

問題描述:

通過自定義sql語句實現列表查詢時產生異常

錯誤日志:


org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:
### Error querying database.  Cause: java.lang.NullPointerException
### The error may exist in file [E:\Program Files\Workspaces\***\***Mapper.xml]
### The error may involve ***_COUNT
### The error occurred while handling results
### SQL: SELECT count(0) FROM **** WHERE ****
### Cause: java.lang.NullPointerException

錯誤原因:

select語句的order條件中使用了as別名,PageHelper版本過低無法處理別名,最終導致程序報錯!

解決方案:

  1. 升級PageHelper插件
  2. 或者 order條件改為使用字段名,不再使用as別名


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM