数据库表中有的冗余字段需要修改,这就要修改多个表中的信息,在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>