開發環境:
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版本過低無法處理別名,最終導致程序報錯!
解決方案:
- 升級PageHelper插件
- 或者 order條件改為使用字段名,不再使用as別名
