Mybatis+Oracle实现按条件分页查询
来源:互联网 发布:靠谱助手网络异常 编辑:程序博客网 时间:2024/06/02 09:38
<select id="selectTrackInfoListByPage" parameterType="com.niwopay.dto.manage.TrackInfoDto"
resultMap="TrackInfoResultMap">
select *
from (select rownum rn, t.*
from (select tti.TRACK_ID,
tti.ORDER_ID,
tti.TRACK_INFO,
tti.TRACK_TIME,
tti.OPERATOR
from TB_TRACK_INF tti
<where>
<if test='orderId != null and orderId!=""'>
tti.ORDER_ID like '%'||#{orderId}||'%'</if>
<if test='startTime != null and startTime!="" '>
<![CDATA[and to_date(tti.TRACK_TIME,'yyyy/mm/dd hh24:mi:ss') >=to_date(#{startTime},'yyyy/mm/dd hh24:mi:ss')]]></if>
<if test='endTime != null and endTime!="" '>
<![CDATA[and to_date(tti.TRACK_TIME,'yyyy/mm/dd hh24:mi:ss') <=to_date(#{endTime},'yyyy/mm/dd hh24:mi:ss')]]></if>
</where>
order by tti.TRACK_ID desc, tti.ORDER_ID desc
) t
<if test='endIndex != null and endIndex!=""' >
<![CDATA[where rownum <=#{endIndex}]]></if>
)
<if test='startIndex != null and startIndex!=""' >
where rn>=#{startIndex}</if>
</select>
resultType="java.lang.String">
select count(*) from TB_TRACK_INF tti
<where>
<if test='orderId != null and orderId!=""'>
tti.ORDER_ID like '%'||#{orderId}||'%'</if>
<if test='startTime != null and startTime!="" '>
<![CDATA[and to_date(tti.TRACK_TIME,'yyyy/mm/dd hh24:mi:ss') >=to_date(#{startTime},'yyyy/mm/dd hh24:mi:ss')]]></if>
<if test='endTime != null and endTime!="" '>
<![CDATA[and to_date(tti.TRACK_TIME,'yyyy/mm/dd hh24:mi:ss') <=to_date(#{endTime},'yyyy/mm/dd hh24:mi:ss')]]></if>
</where>
order by tti.TRACK_ID desc, tti.ORDER_ID desc
resultMap="TrackInfoResultMap">
select *
from (select rownum rn, t.*
from (select tti.TRACK_ID,
tti.ORDER_ID,
tti.TRACK_INFO,
tti.TRACK_TIME,
tti.OPERATOR
from TB_TRACK_INF tti
<where>
<if test='orderId != null and orderId!=""'>
tti.ORDER_ID like '%'||#{orderId}||'%'</if>
<if test='startTime != null and startTime!="" '>
<![CDATA[and to_date(tti.TRACK_TIME,'yyyy/mm/dd hh24:mi:ss') >=to_date(#{startTime},'yyyy/mm/dd hh24:mi:ss')]]></if>
<if test='endTime != null and endTime!="" '>
<![CDATA[and to_date(tti.TRACK_TIME,'yyyy/mm/dd hh24:mi:ss') <=to_date(#{endTime},'yyyy/mm/dd hh24:mi:ss')]]></if>
</where>
order by tti.TRACK_ID desc, tti.ORDER_ID desc
) t
<if test='endIndex != null and endIndex!=""' >
<![CDATA[where rownum <=#{endIndex}]]></if>
)
<if test='startIndex != null and startIndex!=""' >
where rn>=#{startIndex}</if>
</select>
<select id="selectTrackInfoListByPageCount" parameterType="com.niwopay.dto.manage.TrackInfoDto"
resultType="java.lang.String">
select count(*) from TB_TRACK_INF tti
<where>
<if test='orderId != null and orderId!=""'>
tti.ORDER_ID like '%'||#{orderId}||'%'</if>
<if test='startTime != null and startTime!="" '>
<![CDATA[and to_date(tti.TRACK_TIME,'yyyy/mm/dd hh24:mi:ss') >=to_date(#{startTime},'yyyy/mm/dd hh24:mi:ss')]]></if>
<if test='endTime != null and endTime!="" '>
<![CDATA[and to_date(tti.TRACK_TIME,'yyyy/mm/dd hh24:mi:ss') <=to_date(#{endTime},'yyyy/mm/dd hh24:mi:ss')]]></if>
</where>
order by tti.TRACK_ID desc, tti.ORDER_ID desc
</select>
其中
startInde=(page-1)*limit+1; //oracle是从1开始计数的
endIndex=page*limit;
0 1
- Mybatis+Oracle实现按条件分页查询
- Mybatis+Oracle实现按条件分页查询
- Mybatis-实现ORACLE分页查询
- Mybatis+Oracle:条件分页
- Mybatis的条件分页查询
- 带查询条件的Mybatis分页的实现
- oracle+mybatis分页查询
- Mybatis实现条件查询
- MyBatis分页实现 - Oracle
- MyBatis级联多条件分页查询
- mybatis分页条件查询动态sql
- mybatis(3)分页查询和条件分页查询
- mybatis+easyui+Oracle分页查询
- mybatis+oracle实现分页查询--非常简单实用
- mybatis+oracle实现分页查询--非常简单实用
- 针对SpringMVC+Mybatis+Oracle条件分页查询的原创解决方案(超级简单)
- EF实现分页查询+条件查询+排序
- Mybatis实现真正分页查询
- 【C语言提高18】【字符串模型】strstr_while/dowhile
- 汉字统计
- 1026. 程序运行时间(15)
- a.setAttribute('width','200px') and a.style.width="200px"
- 抽屉效果的实现(DrawerLayout和SlidingMenu的对比)
- Mybatis+Oracle实现按条件分页查询
- Java中yield()和join()在线程中的不同
- 逻辑回归、决策树和支持向量机(I)
- OS开发UI篇—手写控件,frame,center和bounds属性
- 为什么指向的是最后一个节点的下一个节点 http://www.zhihu.com/question/20638791
- 自学c语言的第一天(算是吧)
- py2exe打包python程序
- 函数重载与作用域,数组指针
- jsp和js之间的数据流动