The redundant fields in the database table need to be modified, which is to modify the information in multiple tables, how to implement a mapper method in MyBatis?
1. Add allowmultiqueries=true to the JDBC path
Jdbc.jdbcurl=jdbc:mysql://127.0. 0.1:3306/Account?useunicode=true&characterencoding= UTF8&allowmultiqueries=true
2, mapper method of the body directly write multiple SQL can:
<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 execute multiple SQL statements at once