问题如下:
### The error occurred while executing a query
### SQL: SELECT count(0) FROM 表名 WHERE DELETE_FLAG = 0
### Cause: java.sql.SQLSyntaxErrorException: A syntax error has occurred.
; bad SQL grammar []; nested exception is java.sql.SQLSyntaxErrorException: A syntax error has occurred.] with root cause
原因:
com.github.pagehelper.parser
CountSqlParser 类:
com.github.pagehelper.dialect
抽象类 AbstractHelperDialect:
该类中 getCountSql()方法
countColumn 是接下来生成,查询总条数 sql 就是 select count(0)中的 0 这个参数,由于Page 对象默认 CountColumn 不传参默认就0,所以可以为0的时候 加一个判断然后 赋值 * 问题就解决了
解决方法:
建一个 与 Pagehelper包的同包同类名 的 AbstractHelperDialect 然后重新 getCountSql 类 ,利用java 类加载机制修改其源码。