张三通过本文主要向大家介绍了mybatis等相关知识,希望本文的分享对您有所帮助
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}
) uo
where rownum <=#{limit})) ua
where 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);
}
完成

