在使用 Mybatis PageHelper 时发现的一个问题, 在查询数据时确实会把数据给带上了, 然而在统计数量时却并没有添加到条件中!
这里是分页查询的代码
DataPage<T> dataPage = new DataPage<T>();
Page<T> page = PageHelper.offsetPage(param.getStart(), param.getLength());
findList(param);
参数 param
的值有:
- billTime: 2018-07-04T00:00:00.000+0800
- billMonth: 201805
SQL 语句大致如下:
select *
from table
where
a.billTime >= #{billTime}
AND b.chargeperiod like CONCAT('%',#{billMonth},'%')
但是奇怪的事情是
第二个参数在统计数量的时候没有带上, 但在查询数据时都有带上, 有人遇到过类似的问题么?(v^_^)v
统计数量的 SQL 大致是:
select count(*)
from table
a.billTime >= ?
查询数据的 SQL 就是正常的...
select *
from table
where
a.billTime >= ?
AND b.chargeperiod like CONCAT('%',?,'%')
难道说属性名和列名不一致时就不会添加到统计数量的条件中呢?