這篇博客與 上一篇(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>