标签:
代码如下,红色部分为关键代码。
注意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>
标签:
原文地址:http://www.cnblogs.com/jimmy-muyuan/p/5459970.html