java oracle的2种分页方法

java oracle的2种分页方法

一物理分页:

    <!-- 分页查询所有的博客信息 -->
    <select id="findBlogs" resultType="java.util.HashMap" parameterType="Params">
        SELECT * FROM(
            SELECT ROWNUM WN,RN.* FROM (
                SELECT
                    id,
                    title,
                    create_time as createTime,
                    musictor,
                    musictitle
                FROM
                    krry_blog
                ORDER BY create_time desc
            )RN
        )WN
        WHERE WN <= #{pageSize} AND WN > #{pageNo}
    </select>

  

二逻辑分页,利用pagehelper插件

<dependency>
    <groupId>com.github.pagehelper</groupId>
    <artifactId>pagehelper</artifactId>
    <version>4.0.0</version>
</dependency>

  

https://blog.csdn.net//u013142781/article/details/50410243

三逻辑分页,利用mybatis-paginator

<dependency>
        <groupId>com.github.miemiedev</groupId>
        <artifactId>mybatis-paginator</artifactId>
        <version>1.2.10</version>
</dependency>

  

xml

<select id="queryListBlur" flushCache="true" resultType="WxReplyPO">
        select
        reply_id,
        reply_classify,
        reply_type,
        reply_keyword,
        reply_text,
        reply_image,
        is_enable,
        is_delete,
        match_mode,
        create_time,
        update_time
        from ta_wx_reply_c
        WHERE 1=1
        <if test="isEnable != null">
            AND is_enable = #{isEnable}
        </if>
        <if test="isDelete != null">
            AND is_delete = #{isDelete}
        </if>
        <if test="replyClassify != null and replyClassify.trim() != ''">
            AND reply_classify = #{replyClassify}
        </if>
        <if test="replyType != null and replyType.trim() != ''">
            AND reply_type = #{replyType}
        </if>
        <if test="replyKeyword != null and replyKeyword.trim() != ''">
            AND reply_keyword LIKE concat(#{replyKeyword},'%')
        </if>
        <if test="matchMode != null and matchMode.trim() != ''">
            AND match_mode = #{matchMode}
        </if>
        <choose>
            <when test="sidx != null and sidx.trim() != ''">
                order by ${sidx} ${order}
            </when>
            <otherwise>
                order by reply_id desc
            </otherwise>
        </choose>
        <!--<if test="offset != null and limit != null">-->
            <!--limit #{offset}, #{limit}-->
        <!--</if>-->
    </select>

  

IWxReplyService

 List<WxReplyPO> queryListBlur(Map<String, Object> map, PageBounds pageBounds);

  

IWxReplyServiceImpl

@Override
    public List<WxReplyPO> queryListBlur(Map<String, Object> map, PageBounds pageBounds) {
        return taWxReplyCDao.queryListBlur(map, pageBounds);
    }

  

controller

wxReplyService.queryListBlur(attentionPO,
                    new PageBounds(
    Integer.valueOf(request.getPageNo()), //页码
    Integer.valueOf(request.getPageSize()), //条数
    Order.formString("attention_dept_date.desc")) //排序
);        

  

https://blog.csdn.net/szwangdf/article/details/27859847/

原文地址:https://www.cnblogs.com/achengmu/p/11174524.html