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>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章