mybatis的分页如何实现的
以前用的是hibernate来对数据库进行处理,现在换了架构了,改用mybatis,我感觉用起来还是挺顺手的,现在正在理解他的实现过程,现在遇到分页这个难题了,就大神帮忙解释下
接口中的方法是这样的
接口中的方法是这样的
List<T> selectByExampleWithBLOBs(FilterExample example);
List<T> selectByExampleWithRowbounds(FilterExample example, RowBounds rowBounds);xml中的代码是这样的 <select id="selectByExample" resultMap="BaseResultMap" parameterType="com.excenergy.edba.filter.FilterExample" >
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Wed May 21 13:11:55 CST 2014.
-->
select
<if test="distinct" >
distinct
</if>
<include refid="Base_Column_List" />
from LOGIN_LOG
<if test="_parameter != null" >
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null" >
order by ${orderByClause}
</if>
</select> <select resultMap="BaseResultMap" parameterType="com.excenergy.edba.filter.FilterExample" id="selectByExampleWithRowbounds" >
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Wed May 21 13:11:55 CST 2014.
-->
select
<if test="distinct" >
distinct
</if>
<include refid="Base_Column_List" />
from LOGIN_LOG
<if test="_parameter != null" >
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null" >
order by ${orderByClause}
</if>
</select><sql id="Example_Where_Clause" >
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Wed May 21 13:11:55 CST 2014.
-->
<where >
<foreach collection="oredCriteria" item="criteria" separator="or" >
<if test="criteria.valid" >
<trim prefix="(" suffix=")" prefixOverrides="and" >
<foreach collection="criteria.criteria" item="criterion" >
<choose >
<when test="criterion.noValue" >
and ${criterion.condition}
</when>
<when test="criterion.singleValue" >
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue" >
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue" >
and ${criterion.condition}
<foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," >
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>这两段xml代码感觉没什么区别啊,为什么后者能实现分页功能
...全文
相关推荐
MyBatis分页功能实现
一个集成spring的MyBatis的分页功能实现的例子
mybatis使用拦截器实现分页操作
使用mybatis的拦截器功能实现分页操作,使分页代码在整个项目中通用,减少代码冗余。
mybatis分页效果实现代码
主要为大家详细介绍了mybatis分页效果的实现代码,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
MyBatis-Plus 分页查询以及自定义sql分页的实现
主要介绍了MyBatis-Plus 分页查询以及自定义sql分页的实现,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
SSM使用mybatis分页插件pagehepler实现分页示例
本篇文章主要介绍了SSM使用mybatis分页插件pagehepler实现分页示例,使用分页插件的原因,简化了sql代码的写法,实现较好的物理分页,非常具有实用价值,需要的朋友可以参考下


