1 回答
![?](http://img1.sycdn.imooc.com/542820a60001617600970097-100-100.jpg)
TA贡献9条经验 获得超2个赞
resultmap 是用来映射结果集的, resultTyle不同。
<resultMap type="entity.Message" id="MessageResult">
<id column="id_" jdbcType="INTEGER" property="id" />
<result column="command" jdbcType="VARCHAR" property="command" />
<result column="description" jdbcType="VARCHAR" property="description" />
<result column="content" jdbcType="VARCHAR" property="content" />
</resultMap>
<!-- 指定输入参数时只能传递 一个 -->
<!-- #{command} 取得 message 的属性 -->
<!-- where标签 if条件成立时才会连接 -->
<select id="queryMessage" parameterType="entity.Message" resultMap="MessageResult">
select id id_ ,command,description,content from message
<where>
<if test="command != null and !"".equals(command.trim())">
and COMMAND =#{command}
</if>
<if
test="description != null and !"".equals(description.trim())">
and DESCRIPTION like '%' #{description} '%'
</if>
</where>
</select>
添加回答
举报