- <update id="方法名">
- <foreach collection="集合参数名称" item="param" separator=";">
- update 表名 set last_updater_time = now()
- where id =#{param.id}
- </foreach>
- </update>
但Mybatis映射文件中的sql语句默认是不支持以" ; " 结尾的,也就是不支持多条sql语句的执行。所以需要在连接mysql的url上加 &allowMultiQueries=true 这个才可以执行,需要在jdbc的url中指定allowMultiQueries=true
spring.datasource.url=jdbc:mysql://localhost:3306/test?allowMultiQueries=true