第五章 mybatis批量更新update


一、所有的指定id的模型類的同一個字段進行批量更新

實際上:

update t set fileld='xx' where id in (id1,id2,...,idn)

代碼:

<update id="updateBatch" parameterType="Map">
        update t_name
        set name = #{name,jdbcType=VARCHAR}
        where autoid in 
        (
        <foreach collection="list" item="item" separator=",">
            #{item.id,jdbcType=BIGINT}
        </foreach>
        )
    </update>
void updateBatch(@Param("list") List<User> list, @Param("name") String name);

二、指定id的模型類的不同字段進行批量更新

參考:http://blog.csdn.net/tolcf/article/details/39213217

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM