在使用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多参数及实体对象传递实例讲解,希望对大家有所帮助
如对本文有疑问, 点击进行留言回复!!
SpringBoot引用阿里easyexcel,Excel导出返回浏览器下载
HashMap、Hashtable、ConcurrentHashMap三者间的异同
解决RecycleView 中Item包含Edittext时,滑动view复用导致数据错乱的问题
多线程、同步工作原理、死锁案例、Lock接口、线程的生命周期的讲解及实现
网友评论