轉載至:ide
http://www.javashuo.com/article/p-kywecaee-mv.htmlspa
在使用Mybatis的時候,常常會有各類各樣的參數傳遞,不一樣類型,不一樣個數的參數。.net
先上個例子:
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 andlifetouchRelease.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 andlifetouchRelease.page.orderBy != ''">
ORDER BY ${lifetouchRelease.page.orderBy}
</when>
<otherwise>
ORDER BY a.update_date DESC
</otherwise>
</choose>
</select>
blog
上面是一個包含:實體對象,普通類型,多個參數的傳遞。get
多個參數:使用註解的方式實現io
實體對象:實體對象跟普通類型參數傳遞方法同樣,只是在用的時候,以 對象名.(點)對象屬性名 的方式調用就能夠了。
test
其它傳遞,不過數據類型多複雜也是如此。date