背景:Excel表格导入数据,获取到一个 List<Map> list 传入xml文件中,sql语句已经被执行了,但是price被更新后的值是空值。
我直接在mysql里面写批量更新语句之后,也是空值。请问是什么原因?一开始还以为是传入的list有问题,所以把不要的字段去掉了。
后来发现直接在数据库里面写也是空值。。问题应该只是在sql语句上。但是为什么没有值呢?
<!--批量导入 -->
<update id="saveData" parameterType="java.util.List">
UPDATE t_fuli_products
<trim prefix="set price=case productId" suffix="end">
<foreach collection="list" item="i" index="index">
<if test="i.price!=null">
when productId=#{i.productId} then price=#{i.price}
</if>
</foreach>
</trim>
WHERE productId IN
<foreach index="index" item="i" collection="list" separator=","
open="(" close=")">
#{i.productId,jdbcType=VARCHAR}
</foreach>
</update>