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别名
posted @ 2021-02-05 15:57  littleFatty  阅读(1008)  评论(0编辑  收藏  举报