当前位置: 移动技术网 > IT编程>开发语言>Java > Mybatis多参数及实体对象传递实例讲解

Mybatis多参数及实体对象传递实例讲解

2019年07月22日  | 移动技术网IT编程  | 我要评论

在使用mybatis的时候,经常会有各种各样的参数传递,不同类型,不同个数的参数。

先上个例子:

 public list<lifetouchrelease> findofficelist(@param("lifetouchrelease") lifetouchrelease lifetouchrelease,
      @param("advertisementid") string advertisementid, @param("officename") string officename,
      @param("isonline") integer isonline);
  <select id="findofficelist" resulttype="lifetouchrelease">
    select 
      <include refid="lifetouchreleasecolumns"/>
    from lifetouch_release a
    <include refid="lifetouchreleasejoins"/>
    <where>
      <if test="lifetouchrelease.typeidentification > 0">
        and a.type_identification = #{lifetouchrelease.typeidentification}
      </if>
      <if test="lifetouchrelease.category != null andlifetouchrelease.category.id != null and lifetouchrelease.category.id != ''">
        and a.release_type_id = #{lifetouchrelease.category.id}
      </if>
      and a.office_id is not null 
      and a.advertisement_id like '%${advertisementid}%' 
      and (select name from sys_office where id=a.office_id) like '%${officename}%'
      <if test="isonline != null">
        and a.del_flag = #{isonline}
      </if>
    </where>
    <choose>
      <when test="lifetouchrelease.page !=null andlifetouchrelease.page.orderby != null and lifetouchrelease.page.orderby != ''">
        order by ${lifetouchrelease.page.orderby}
      </when>
      <otherwise>
        order by a.update_date desc
      </otherwise>
    </choose>
  </select>

上面是一个包含:实体对象,普通类型,多个参数的传递。

多个参数:使用注解的方式实现

实体对象:实体对象跟普通类型参数传递方法一样,只是在用的时候,以 对象名.(点)对象属性名 的方式调用就可以了。

其它传递,不过数据类型多复杂也是如此。

以上所述是小编给大家介绍的mybatis多参数及实体对象传递实例讲解,希望对大家有所帮助

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网