【ibatis】ssi 框架 ibatis 分页实现

来源:互联网 发布:c#9语言高级编程 pdf 编辑:程序博客网 时间:2024/06/01 08:57

1、example文件修改 

protected Integer limitStart;protected Integer limitEnd;protected RepDayExample(RepDayExample example) {this.orderByClause = example.orderByClause;this.oredCriteria = example.oredCriteria;//原方法基础上添加this.limitEnd = example.limitEnd;this.limitStart = example.limitStart;}public void setLimitStart(Integer limitStart) {this.limitStart = limitStart;}public Integer getLimitStart() {return limitStart;}public void setLimitEnd(Integer limitEnd) {this.limitEnd = limitEnd;}public Integer getLimitEnd() {return limitEnd;}

2、mapper 文件修改

  <select id="abatorgenerated_selectByExample" resultMap="abatorgenerated_RepDayResult" parameterClass="com.imopan.game.channel.model.RepDayExample" >    <!--      WARNING - This element is automatically generated by Abator for iBATIS, do not modify.      This element was generated on Tue Nov 17 20:01:19 CST 2015.    -->    select ID, DATA_TIME, PRODUCT_ID, GAME_NAME, CHANNEL_ID, CHANNEL_NAME, PARENT_CN_ID,      PARENT_CN_NAME, REGISTER_NUM, REGISTER_UID_NUM, PAY_NUM, PAY_MONEY, CONSUME_NUM,      CONSUME_MONEY, INSERT_TIME    from REP_DAY    <isParameterPresent >      <include refid="REP_DAY.abatorgenerated_Example_Where_Clause" />      <isNotNull property="orderByClause" >        order by $orderByClause$      </isNotNull>      <!-- 原基础上添加即可 -->      <isNotNull property="limitStart">        limit $limitStart$,$limitEnd$      </isNotNull>    </isParameterPresent>  </select>

3、测试

public static void main(String[] args) {ApplicationContext ac = new FileSystemXmlApplicationContext("src/main/resources/beans.xml");RepDayDAO memberDAO = (RepDayDAO) ac.getBean("repDayDAO");RepDayExample example = new RepDayExample();example.setLimitStart(0);example.setLimitEnd(2);List<BindMember> bindMembers = memberDAO.selectByExample(example);System.out.println(bindMembers.size());}




0 0
原创粉丝点击