MyBatis的Mapper.xml怎么同时执行多个sql语句

2025-01-25 03:42:42
推荐回答(1个)
回答1:

1、修改数据库连接参数加上allowMultiQueries=true,如:

hikariConfig.security.jdbcUrl=jdbc:mysql://xx.xx.xx:3306/xxxxx?characterEncoding=utf-8&autoReconnect=true&failOverReadOnly=false&allowMultiQueries=true

2、直接写多条语句,用“;”隔开即可


delete from sec_user_role where userId=#{id};
delete from sec_user where id=#{id};