这篇博客与 上一篇(mybatis+sqlserver批量update操作数据库报错:The server supports a maximum of 2100 parameters) 的解决办法一样。
1. serverImpl里面。
绿色框的items.size() ,可能超过2100,但是只要超过就会报错,所以也要这样处理。
2. Mapper(也就是DAO层)里面
3. Mapper.xml里面
<!-- 从sap读取生产订单 --> <insert id="createProductionOrderFromSap" parameterType="com.kent.qr.model.FormSapProductionOder" useGeneratedKeys="true" keyProperty="orderNo"> insert into production_order( plant , production_order , order_type , batch_no , customer_code ,customer_name , material_no , mode_no , cust_material_no , order_qty , uom , packing_category , country , mpt , mpq , mpt_material_no , length , width , high , apt , apq , assortment_id , assortment_description ,total_carton_qty , upload_time , rel_date , locco , airplane_type , zscxs , status , status_msg )values <foreach collection="items2" item="po" separator=","> ( #{po.plant}, #{po.productionOrderNo}, #{po.orderType}, #{po.batchNo}, #{po.customerCode}, #{po.customerName}, #{po.materialNo}, #{po.moldNo}, #{po.custMaterialNo}, #{po.orderQty}, #{po.uom}, #{po.packingCategory}, #{po.country}, #{po.mpt}, #{po.mpq}, #{po.mptMaterialNo}, #{po.length}, #{po.width}, #{po.high}, #{po.apt}, #{po.apq}, #{po.assortmentID}, #{po.assortmentDescription}, #{po.totalCartonQty}, #{po.uploadTime}, #{po.relDate}, #{po.locco}, #{po.airplaneType}, #{po.zscxs}, #{po.status}, #{po.statusMsg} ) </foreach> </insert>