mybatis標籤set

使用set標籤可以將動態的配置 SET 關鍵字,並剔除追加到條件末尾的任何不相關的逗號

目前最長見的應用場景就是 update的時候 if 和set 配合使用,別的功能不知道了

    <update id="dynamicSetTest" parameterType="Blog">
        update t_blog
        <set>
            <if test="title != null">
                title = #{title},
            </if>
            <if test="content != null">
                content = #{content},
            </if>
            <if test="owner != null">
                owner = #{owner}
            </if>
        </set>
        where id = #{id}
    </update>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章