Pagination 为什么mybatis不提供分页查询?
Spring data jpa有分页查询,也有许多需要分页的场景,为什么mybatis只提供Pagination 为什么mybatis不提供分页查询?,pagination,mybatis,Pagination,Mybatis,Spring data jpa有分页查询,也有许多需要分页的场景,为什么mybatis只提供selectList?如何在mybatis中实现分页?有人能给我帮助吗?你必须传递一个RowBounds的实例进行分页,例如: mybatisTemplate.selectList("query", params, new RowBounds(offset, limit)); 使用Mybatis PageHelper的步骤 外接程序pom.xml <dependency> <g
selectList
?如何在mybatis中实现分页?有人能给我帮助吗?你必须传递一个RowBounds
的实例进行分页,例如:
mybatisTemplate.selectList("query", params, new RowBounds(offset, limit));
使用Mybatis PageHelper的步骤 外接程序pom.xml
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
<version>x.x.x</version>
</dependency>
后果:
1) 您不必在sql中实现分页
2) mybatis pagehelper将生成所需的分页sql
希望上述帮助您可以使用名为Mybatis PageHelper()的插件来帮助您。
<!--
In the configuration file,
plugins location must meet the requirements as the following order:
properties?, settings?,
typeAliases?, typeHandlers?,
objectFactory?,objectWrapperFactory?,
plugins?,
environments?, databaseIdProvider?, mappers?
-->
<plugins>
<plugin interceptor="com.github.pagehelper.PageInterceptor">
<!-- config params as the following -->
<property name="param1" value="value1"/>
</plugin>
</plugins>
mybatisTemplate.selectList("query", params, new RowBounds(offset, limit));