MyBatis嵌套查询column传多个参数描述

代码如下,红色部分为关键代码。

 

注意parameterType要为java.util.HashMap

 

<resultMap id="baseResultMap" type="Blog">

  <association property="author" column="{id=author_id,likename=author_name}" javaType="Author" select="selectAuthor"/>

</resultMap>

 

 

<select id="selectAuthor" resultType="Author" parameterType="java.util.HashMap">

  SELECT * FROM AUTHOR WHERE 1=1

  <if test="id != null and id != '' ">

         and ID = #{id} 

  </if>

  <if test="likename != null and likename != '' ">

         and name like CONCAT('%',#{likename},'%')

  </if>

 <if test="author_id!= null and author_id!= '' ">

         and id=#{author_id}

  </if>

</select>

posted @ 2016-05-04 21:58  煮海焚天  阅读(1356)  评论(0编辑  收藏  举报