传入一个List,List中是要修改的实体类,用foreach组装多条update,这样只用建立一个链接,速度快不少
<update id="deleteBaseCourseByCourseIds" parameterType="Long">
<foreach collection="array" item="item" index="index" open="" close="" separator=";">
update base_course
<set>
is_deleted='2', del_unique_key=#{item}
</set>
where course_id = #{item}
</foreach>
</update>
注意!!!
但Mybatis映射文件中的sql语句默认是不支持以" ; " 结尾的,也就是不支持多条sql语句的执行。所以需要在连接mysql的url上加 &allowMultiQueries=true 这个才可以执行。