mabatis实现动态更新字段

利用if标签实现

<update id="updateUser" parameterType="xxx.pojo.user">
    update cmtinfo
     <trim prefix="set" suffixOverrides=",">
            <if test="name!=null">name=#{name},</if>
            <if test="sex!=null">sex=#{sex},</if>
            <if test="nation!=null">nation=#{nation},</if>
            <if test="birth!=null">birth=#{birth},</if>
        </trim>
    </update> 

猜你喜欢

转载自blog.csdn.net/qq_37728271/article/details/83044092