-
Notifications
You must be signed in to change notification settings - Fork 233
FAQ
Ben edited this page Apr 22, 2018
·
2 revisions
由于limit并不是标准SQL,仅少数数据库支持该种方法(如MySQL),所以目前分页插件只支持在sql语句中以limit/offset
的方式进行分页。
如果要在不支持limit的数据库中进行分页查询,则需要使用其他方法来进行分页查询。
- 向Mapper方法传入rowBounds,mapper.xml中不需要任何配置,mybatis会自动拦截rowBonds进行分页操作
RowBounds rowBounds = new RowBounds(offset, pageSize);
public List<ProdProduct> findRecords(HashMap<String,Object> map,RowBounds rowBounds);
在调用查询方法之前调用。PageHelper只对紧跟着的第一个SQL语句起作用.
Page<?> page = PageHelper.startPage(pageNum,pageSize);
List<?> pagelist = selectByExample(example);