mybatis一括更新(update foreach)の失敗の解決
3249 ワード
<update id="updateIssueByBatch" parameterType="java.util.List">
<foreach collection="issueList" item="item" index="index" separator=";">
update sys_issue
<set>
<if test="item.first != null and item.first != ''">first_class = #{item.first}, if>
<if test="item.second != null and item.second != ''">second_class = #{item.second}, if>
updated_time = now()
set>
where id = #{item.Id}
foreach>
update>
报错如下:
The error occurred while setting parameters
问题描述:
上网查询说是 配置mysql的时候没有开启批量插入,就查询了项目 是否 配置了 allowMultiQueries=true
,发现本地和线上都配置了该语句,问题没出在这。那么问题出在哪呢?后来发现是由于线上将 &
变成了 &
造成的。
* 前后对比如下:*
修改前:
jdbc.url=jdbc:mysql://XXX/abc?useUnicode=true&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true
修改后:
jdbc.url=jdbc:mysql://XXX/abc?useUnicode=true&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true