<update  id="id" parameterType="Dto">
   <foreach item="item" collection="是一个list" >
       update test set t.A=#{item.a},t.b='success' where  t.id=#{item.id}
   </foreach>
</update>我想这么写。但是报错。假如list里面有两条记录打印Sql如下:
update test set t.A=a,t.b='success' where  t.id=1 update test set t.A=a1,t.b='success' where  t.id=2 mybatis 中的Sql是不能这么写的。希望大家给我一个思路。

解决方案 »

  1.   

    加一个<if test=""><if>进行判断,这样不知道行不行
      

  2.   

    这个必须报错。update test set t.A=a,t.b='success' where  t.id=1。这里的t是什么要是给test的别名的话不能这么写
      

  3.   


    错误就是他把两个update语句拼起来,就发给Oracle了。oracle 肯定不识别,不是循环完一次就发给oracle,循环完第二次就发给oracle。
      

  4.   

    我们连sqlserver,mybatis的批量更新写的和你一样,只是{item.a,jdbcType=?}  更新我不知道,批量插入如果不写jdbcType 会报错