oracle 配合mybatis example分页

来源:互联网 发布:linux vi 模式 编辑:程序博客网 时间:2024/05/20 23:03

mybatis逆向生成的xml 内增加 分页

<select id="selectByPage" parameterType="map" resultMap="BaseResultMap">select<include refid="Base_Column_List" />from((select rownum rn,uo.* from(select * from mytable <if test="_parameter != null"><include refid="Update_By_Example_Where_Clause" /></if>            order by ${example.orderByClause}      ) uowhere rownum <=#{limit})) uawhere ua.rn>#{start}</select>
Update_By_Example_Where_Clause

接口增加

    List<tableObject> selectByPage(@Param("start") int start,@Param("limit") int limit,@Param("example") tableObjectExample example);
service为

public List<tableObject> getByCcidsP(List<Long> ccids,String pageNo,String pageSize){CouponCashExample example = new CouponCashExample();example.createCriteria().andCcidIn(ccids);int pageSizeI = Integer.parseInt(pageSize);int pageNoI = Integer.parseInt(pageNo);int start = (pageNoI-1)*pageSizeI;int limit = (pageNoI)*pageSizeI;example.setOrderByClause("ccid");return CouponCashMapper.selectByPage(start, limit, example);}

完成