欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

mybatis批量更新

程序员文章站 2022-03-10 18:37:56
...
        <update id="updateBatch" parameterType="java.util.ArrayList">
	        UPDATE USER
	        <trim prefix="set" suffixOverrides=",">
	            <trim prefix="USER_NAME =case" suffix="end,">
	                <foreach collection="userList" item="user" index="index">
	                     when userId=#{user.userId} then #{user.userName}
	                </foreach>
	            </trim>
	            <trim prefix="USER_AGE =case" suffix="end,">
	                <foreach collection="userList" item="user" index="index">
	                     when userId=#{user.userId} then #{user.userAge}
	                </foreach>
	            </trim>
	        </trim>
	        WHERE userId in
	        <foreach collection="userList" index="index" item="user" separator="," open="(" close=")">
	            #{user.userId}
	        </foreach>
	    </update>
mybatis批量更新