mybatis之(Oracle,MySql)批量更新
程序员文章站
2022-05-28 11:38:41
...
Oracle和MySql批量更新配置文件不太一样。
Oracle:
<!-- 对应关系批量更新 -->
<update id="hotelCusRelUpdate" parameterType="java.util.List">
<foreach collection="list" item="hotelCusRel" separator=";">
update interface_hotel_account
<set>
hotel_account = #{hotelCusRel.hotelAccount},
hotel_name = #{hotelCusRel.hotelName},
customer_code = #{hotelCusRel.customerCode},
business_partner_code = #{hotelCusRel.businessPartnerCode}
</set>
where rel_id = #{hotelCusRel.relId}
</foreach>
</update>
MySql:
MySql和Oracle在Mybatis中操作同上,但是配置文件中需要加上&allowMultiQueries=true,例如:
spring.datasource.url=jdbc:mysql://localhost:3306/ifp_base?useUnicode=true&characterEncoding=UTF-8
&allowMultiQueries=true