标签:
<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>
标签:
原文地址:http://www.cnblogs.com/dxiaoer/p/5039580.html