您的位置:首页 > 其它

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

2016-05-04 21:58 295 查看
代码如下,红色部分为关键代码。

注意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="[b]author_id!= null and author_id!= '' ">[/b]

and id=#{[b]author_id}[/b]

</if>

</select>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: