小弟想要批量update数据,以便减少与Oracle的交互。使用mybatis。
我一种写法:
<update id="batchUpdateTest" parameterType="java.util.List">
<foreach collection="list" item="i" separator="" open="begin" close="end;"> update table_x set name=#{i.name} where id= #{i.id};
</foreach>
</update>但发现效率还不如一条一条update,多次交互更新。试问大伙,有没有其他的写法,增加效率的???
mybatisoracle批量update
我一种写法:
<update id="batchUpdateTest" parameterType="java.util.List">
<foreach collection="list" item="i" separator="" open="begin" close="end;"> update table_x set name=#{i.name} where id= #{i.id};
</foreach>
</update>但发现效率还不如一条一条update,多次交互更新。试问大伙,有没有其他的写法,增加效率的???
mybatisoracle批量update
另外,我一般这么写 <insert id="insertBatch" parameterType="mybatis.bean.TTest3">
insert into test3(name,value,ftname)values
<foreach collection="list" item="item" index="index" separator=",">
(#{item.name},#{item.value},'')
</foreach>
</insert>
项目要求用mybatis,我也没办法……
不是数据了的问题……我只是测试10条数据的update。
mybatis完全是靠List数据拼出十条update……应该不是数据了的问题