现在的一些互联网应用 为了提高性能,现在一般比较少的使用外键。不是不用,只是在创建数据库不标明外键关系,用程序去维护。
为了维护数据一致性,我们需要手动完成相关数据的删除
比如用户和用户的关注 当用户删除了以后,我们就要删除用户的关注。
那mybatis怎么执行多条语句? 这里使用的是mysql数据库
1、修改数据库连接参数加上allowMultiQueries=true,如:
jdbc.url=jdbc:mysql://xx.xx.xx:3306/xxxxx?characterEncoding=utf-8&allowMultiQueries=true
2 mybatis配置 直接写多条语句,用“ ;”隔开即可
<delete id="deleteUserRelaById" > delete from user_concern where userId=#{id}; delete from user where userid=#{id}; </delete>