码迷,mamicode.com
首页 > 数据库 > 详细

mybatis一次执行多条SQL语句

时间:2018-05-17 15:18:32      阅读:369      评论:0      收藏:0      [点我收藏+]

标签:where   冗余   code   har   attr   执行   HERE   div   mybatis   

数据库表中有的冗余字段需要修改,这就要修改多个表中的信息,在mybatis中如何实现一个mapper方法?

1、在jdbc路径中添加 allowMultiQueries=true

jdbc.jdbcUrl=jdbc:mysql://127.0.0.1:3306/account?useUnicode=true&characterEncoding=utf8&allowMultiQueries=true

2、mapper方法体内部直接写多个sql即可:

<update id="updateComName" parameterType="com..core.model.BaCompany" >
    update ba_company
    set company_name = #{companyName,jdbcType=VARCHAR},
    upd_time = #{updTime,jdbcType=TIMESTAMP},
    upd_user = #{updUser,jdbcType=VARCHAR}
    where company_id = #{companyId,jdbcType=VARCHAR};

    update ba_member
    set company_name = #{companyName,jdbcType=VARCHAR},
         upd_time = #{updTime,jdbcType=TIMESTAMP},
         upd_user = #{updUser,jdbcType=VARCHAR}
    where company_id = #{companyId,jdbcType=VARCHAR};

    update ba_account
    set company_name = #{companyName,jdbcType=VARCHAR},
      upd_time = #{updTime,jdbcType=TIMESTAMP},
      upd_user = #{updUser,jdbcType=VARCHAR}
    where company_id = #{companyId,jdbcType=VARCHAR}
  </update>

 

mybatis一次执行多条SQL语句

标签:where   冗余   code   har   attr   执行   HERE   div   mybatis   

原文地址:https://www.cnblogs.com/wujh88/p/9050832.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!