码迷,mamicode.com
首页 > 数据库 > 详细

MyBatis-Oracle分页

时间:2019-11-07 09:30:07      阅读:88      评论:0      收藏:0      [点我收藏+]

标签:list   bat   type   -o   cdata   order   size   use   col   

<select id="selectListPage" resultType="User">
SELECT id,name,password FROM(
SELECT id,name,password,ROWNUM rn FROM t_user
<where>
<if test="id!=null and id!=‘‘">AND id=#{id}
</if>
<if test="
name!=null and name!=‘‘">
AND name like #{name}
</if>
<if test="password!=null and password!=‘‘">
AND password like #{password}
</if>
</where>
<if test="columnName!=null and columnName!=‘‘">
ORDER BY ${columnName} ${sortType}
</if>
) WHERE rn&gt;(#{page}-1)*#{pageSize} AND rn&lt;=#{page}*#{pageSize}
</select>

 

 

<select id="selectListPage" resultMap="rm">

SELECT id,name,password,role FROM(
SELECT id,name,password,role,ROWNUM rn FROM t_user
<where>
<if test="id!=null and id!=‘‘">AND id=#{id}
</if>
<if test="
name!=null and name!=‘‘">
AND name like #{name}
</if>
<if test="password!=null and password!=‘‘">
AND password like #{password}
</if>
</where>
<if test="columnName!=null and columnName!=‘‘">
ORDER BY ${columnName} ${sortType}
</if>
)
<![CDATA[
WHERE rn>(#{page}-1)*#{pageSize} AND rn<=#{page}*#{pageSize}
]]>
</select>

MyBatis-Oracle分页

标签:list   bat   type   -o   cdata   order   size   use   col   

原文地址:https://www.cnblogs.com/java-ty/p/11809894.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!