- prefix trim标签内sql语句加前缀
- suffix 加后缀
- prefixOverrides 去除多余的前缀
- suffixOverrides 去除多余的后缀
<insert id="insert" parameterType="com.tortuousroad.groupon.cart.entity.Cart">
insert into cart
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="userId != null">
user_id,
</if>
<if test="count != null">
count,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=BIGINT},
</if>
<if test="userId != null">
#{userId,jdbcType=BIGINT},
</if>
<if test="count != null">
#{count,jdbcType=INTEGER},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<update id="update" parameterType="com.bank.vo.Pledge">
update bank_pledge
<trim prefix="set" suffixOverrides=",">
<if test="certificate!=null">
certificate=#{certificate,jdbcType=VARCHAR},
</if>
</trim>
where id=#{id}
</update>