<update id="addYearPlan" parameterType="List">
<foreach collection="list" separator=";" item="item">
update yearplan_header
<set>
plannedSalesTarget=#{item.plannedSalesTarget,jdbcType=DECIMAL},
plannedProfitTarget=#{item.plannedProfitTarget,jdbcType=DECIMAL}
</set>
<where>
id=#{item.id,jdbcType=VARCHAR}
</where>
</foreach>
</update>
以上为mybatis mapper代码,数据传过来的是一个list集合里面是实体类,运行程序后台不报错,同时数据也没有插进去,数据库链接的时候加入了allowMultiQueries=true
mapper里的表名、字段名都写对了吗,或者update有没有传id
第一种方式
[html] view
plain copy
print?
update id="updateBatch" parameterType="Map">
update aa set
a=#{fptm},
b=#{csoftrain} ......
答案就在这里:Mybatis批量更新问题SQL语法错误
----------------------Hi,地球人,我是问答机器人小S,上面的内容就是我狂拽酷炫叼炸天的答案,除了赞同,你还有别的选择吗?