Mybatis3.0如何做批量update
我用的是<updateid="updateCustomerData"><foreachcollection="list"item="item"index="index">...
我用的是<update id="updateCustomerData" >
<foreach collection="list" item="item" index="index" >
update t_customer set
SRID=#{item.srID},
CUSTID=#{item.custID},
CUSTNAME=#{item.custName},
CUSTADDRESS=#{item.custAddress},
DELIVERYADDRESS=#{item.deliveryAddress},
PHONE1=#{item.phone1},
PHONE2=#{item.phone2},
CONTACT=#{item.contact},
COMPCODE=#{item.compCode},
CONSUMERCHANNEL=#{item.consumerChannel},
CUSTCHANNEL=#{item.custChannel},
VIVIDCHANNEL=#{item.vividChannel},
SALELEVEL=#{item.saleLevel},
CUSTTYPE=#{item.custType},
CARRIERSID=#{item.carriersID},
MARKET=#{item.market},
STATUS=#{item.status},
DELIVERYPLANT=#{item.deliveryPlant},
VISITMON=#{item.visitMon},
VISITTUE=#{item.visitTue},
VISITWED=#{item.visitWed},
VISITTHU=#{item.visitThu},
VISITFRI=#{item.visitFri},
VISITSTA=#{item.visitSta},
VISITSUN=#{item.visitSun},
ARRIVEDATETIME=#{item.arriveDateTime}
where CUSTID=#{item.custID}
</foreach>
</update>
但是执行的时候,报错 展开
<foreach collection="list" item="item" index="index" >
update t_customer set
SRID=#{item.srID},
CUSTID=#{item.custID},
CUSTNAME=#{item.custName},
CUSTADDRESS=#{item.custAddress},
DELIVERYADDRESS=#{item.deliveryAddress},
PHONE1=#{item.phone1},
PHONE2=#{item.phone2},
CONTACT=#{item.contact},
COMPCODE=#{item.compCode},
CONSUMERCHANNEL=#{item.consumerChannel},
CUSTCHANNEL=#{item.custChannel},
VIVIDCHANNEL=#{item.vividChannel},
SALELEVEL=#{item.saleLevel},
CUSTTYPE=#{item.custType},
CARRIERSID=#{item.carriersID},
MARKET=#{item.market},
STATUS=#{item.status},
DELIVERYPLANT=#{item.deliveryPlant},
VISITMON=#{item.visitMon},
VISITTUE=#{item.visitTue},
VISITWED=#{item.visitWed},
VISITTHU=#{item.visitThu},
VISITFRI=#{item.visitFri},
VISITSTA=#{item.visitSta},
VISITSUN=#{item.visitSun},
ARRIVEDATETIME=#{item.arriveDateTime}
where CUSTID=#{item.custID}
</foreach>
</update>
但是执行的时候,报错 展开
1个回答
展开全部
<delete id="deleteForBatch" parameterType="List">
delete from t_backup where
<foreach collection="list" item="item" index="index" separator="or">id = #{item}</foreach>
</delete>参考一下,不过我建议还是自己用jdbc批量,你可以使用一个jdbctemplate做辅助接口...
那个批处理个人感觉还更好点...
delete from t_backup where
<foreach collection="list" item="item" index="index" separator="or">id = #{item}</foreach>
</delete>参考一下,不过我建议还是自己用jdbc批量,你可以使用一个jdbctemplate做辅助接口...
那个批处理个人感觉还更好点...
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询