mybatis常用语句

<trim>标签中,prefix 前缀,suffix后缀,

suffixOverrides语句最后如果有指定符号,则去除此符号, prefixOverrides语句最前面如果有指定符号,则去除此符号 (可以用 | 包含多种情况)

插入/更新语句注意逗号!!!

插入语句:

<insert id="insertSelective" parameterType="com.hc.backData.model.Mpoint">
insert into T_MPOINT
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="mpointid != null">
MPOINTID,
</if>
<if test="mpointname != null">
MPOINTNAME,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="mpointid != null">
#{mpointid,jdbcType=VARCHAR},
</if>
<if test="mpointname != null">
#{mpointname,jdbcType=VARCHAR},
</if>
</trim>
</insert>

更新语句

<update id="updateMpoint" parameterType="com.hc.backData.model.Mpoint">
UPDATE T_MPOINT
<trim prefix="SET" suffixOverrides=",">
<if test="mpointname != null">
MPOINTNAME = #{mpointname,jdbcType=VARCHAR},
</if>
<if test="mpointtag != null">
MPOINTTAG = #{mpointtag,jdbcType=VARCHAR},
</if>
</trim>
WHERE MDM_ID = #{mdmId,jdbcType=VARCHAR}
</update>

上一篇:D3_book 11.1 pie


下一篇:phpstorm2019永久激活