功能
想实现在mapper的一个更新操作中执行多条update语句
效果如下:
<update id="ModifyDefault" parameterType="map">
update hospital.sick s
set s.s_defalut = '0'
where s.s_pid = #{openid}
and s.s_defalut = '1';
update hospital.sick s
set s.s_licence = '1'
where s.s_pid = #{openid}
and s.s_licence = #{licence};
</update>
mybatis默认不开启sql语句的批处理,需要在数据库配置中配置相关参数:
在数据源的url中的查询字符串参数追加&allowMultiQueries=true即可
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/hospital?useSSL=false&allowMultiQueries=true&useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai
更多推荐
Mybatis多条update/insert/delete执行
发布评论