mybatisPlus的PageHelper中count()方法导致数字开头的表进行分页时候出现 不支持该SQL转换为分页查询

今天发现个很奇葩的bug,使用PageHelp进行分页时候,表名如果是数字开头,那么就会出现以下使用PageHelper进行分页时候,数字开头的表,在select count(0)时候,会报错 不支持该SQL转换为分页查询

报错内容如下:

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: 
### Error querying database.  Cause: com.github.pagehelper.PageException: 不支持该SQL转换为分页查询!
### The error may exist in file [E:\WorkSpace\RuiShu\target\classes\mapper\TbFormDataList.xml]
### The error may involve com.cric.ruishu.mapper.dataList.TbFormListDataMapper.searchDataOr_COUNT
### The error occurred while handling results
### SQL: select count(0) from (SELECT                           *                       from [1]         where                           1=1) tmp_count
### Cause: com.github.pagehelper.PageException: 不支持该SQL转换为分页查询!
    at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:92)
    at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:440)
    at com.sun.proxy.$Proxy120.selectList(Unknown Source)
    at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:223)
    at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.executeForMany(MybatisMapperMethod.java:158)
    at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:76)

但是 select count(0) from (SELECT  *   from [1]  where 1=1) tmp_count明明在数据库里可以执行啊。

我于是干脆自写一个count方法,写了个SELECT count(0) from [1] where 1=1

结果还是一样的报错。

 

找了半天,初步怀疑是SqlServerParser.convertToPageSql的 转换为分页语句 这个方法中的

CCJSqlParserUtil.parse(sql)

出错,但是具体什么原因,尚不清楚。

最后实在是找不到原因,干脆给所有表加英文前缀。

没找到bug原因,只能绕过去了,唉。

 

 

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值