1.在insert时使用

insert into
    wechat_pay_payment_detail
<trim prefix="(" suffix=")" suffixOverrides=",">
    <if test="entity.arg01 != null">openid,</if>
    <if test="entity.arg02 != null">share_flag,</if>
    <if test="entity.arg03 != null">share_openid,</if>
    <if test="entity.arg04 != null">pay_flag,</if>
    <if test="entity.arg05 != null">order_no,</if>
    <if test="entity.arg06 != null">fee,</if>
    <if test="entity.arg07 != null">share_pay_flag,</if>
</trim>
<trim prefix="values(" suffix=")" suffixOverrides=",">
    <if test="entity.arg01 != null">entity.openid,</if>
    <if test="entity.arg02 != null">entity.share_flag,</if>
    <if test="entity.arg03 != null">entity.share_openid,</if>
    <if test="entity.arg04 != null">entity.pay_flag,</if>
    <if test="entity.arg05 != null">entity.order_no,</if>
    <if test="entity.arg06 != null">entity.fee,</if>
    <if test="entity.arg07 != null">entity.share_pay_flag,</if>
</trim>

2.在update时使用
update user
<trim prefix="set" suffixoverride="," suffix=" where id = #{id} ">
    <if test="name != null and name.length()>0">name=#{name},</if>
    <if test="gender != null and gender.length()>0">gender=#{gender},</if>
</trim>

3.在select时使用
select * from user
<trim prefix="WHERE" prefixOverrides="AND |OR">
    <if test="name != null and name.length()>0"> AND name=#{name}</if>
    <if test="gender != null and gender.length()>0"> AND gender=#{gender}</if>
</trim>