为了账号安全,请及时绑定邮箱和手机立即绑定

mybatis的resultmap用法

mybatis的resultmap用法

醉清风tomorrow 2016-10-26 13:43:20
mybatis的resultmap用法是怎样的,能举例吗
查看完整描述

1 回答

已采纳
?
简单丶注定

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 !&quot;&quot;.equals(command.trim())">
    and COMMAND =#{command}
   </if>
   <if
    test="description != null and !&quot;&quot;.equals(description.trim())">
    and DESCRIPTION like '%' #{description} '%'
   </if>
  </where>
 </select>



查看完整回答
反对 回复 2016-10-26
  • 1 回答
  • 0 关注
  • 1768 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信