MyBatis批量更新,update设置多个字段值,where条件为集合

import org.apache.ibatis.annotations.Param;

//接口
void setStaff(@Param("channels")List<ChatChannel> channels, @Param("staffId") String staffId, @Param("staffName") String staffName);
	<update id="setStaff" >
		UPDATE chat_channel SET 	
			staff_id = #{staffId},
			staff_name = #{staffName}
		WHERE id IN
		    <foreach collection="channels" index="index" item="item" open="(" separator="," close=")">
		        #{item.id}
		    </foreach>
	</update>

猜你喜欢

转载自feng-tai-jun.iteye.com/blog/2389049