Mybatis下 Mapper(Update)逗号位置

<update id="update" parameterType="map">
        update t_role
        <set> 
        <if test="name != null and name !=''">
            name=#{name},
        </if>
        <if test="msg != null and msg !=''">
            msg=#{msg},
        </if>
        <if test="type != null and type !=''">
            type=#{type},
        </if>
        <if test="creator_id != null and creator_id !=''">
            creator_id=#{creator_id},
        </if>
        <if test="level != null and level !=''">
            level=#{level}
        </if>
</set>
where id=#{id} </update>

使用 <set></set>可以智能去掉最后一个逗号,十分方便!

posted @ 2019-02-12 13:06  DebuGger丶  阅读(1496)  评论(0)    收藏  举报