zoukankan      html  css  js  c++  java
  • SSM批量插入和修改实现实例

    1.Service,自己对代码逻辑进行相应处理

     1 /* 新增订单产品信息 */
     2         List<DmsOrderProduct> insertOrderProductList = Lists.newArrayList();
     3         for (DmsOrderProductVo op : orderVo.getProductList()) {
     4             insertOrderProductList.add(op);
     5         }
     6 
     7         /* 批量新增订单商品信息 */
     8         if (!insertOrderProductList.isEmpty()) {
     9             dmsOrderProductService.batchInsert(insertOrderProductList);
    10         }
    没写接口,自己处理下
    1
    @Override 2 public void batchInsert(List<DmsOrderProduct> orderProductList) { 3 dmsOrderProductMapper.batchInsert(orderProductList); 4 }

    2.持久层

    1  /**
    2      * 批量新增订单产品信息
    3      * @param orderProductList
    4      */
    5     void batchInsert(List<DmsOrderProduct> orderProductList);
     1 <!-- 批量新增订单产品信息 -->
     2   <insert id="batchInsert" parameterType="java.util.List">
     3     insert into dms_order_product
     4     (
     5       order_id, product_id, product_code, product_name, product_spec_id, spec_union_key, shoppingcart_id, unit, original_price,
     6       price, count, return_count, status, promotion_product_id, promotion_subject, created_date, created_by,
     7       last_updated_date, last_updated_by, remove_flag, weight, volume, short_name, spec_name
     8     )
     9     values
    10     <foreach collection="list" index="index" item="item" separator=",">
    11       (
    12         #{item.orderId}, #{item.productId}, #{item.productCode}, #{item.productName}, #{item.productSpecId},
    13         #{item.specUnionKey},#{item.shoppingcartId}, #{item.unit}, #{item.originalPrice}, #{item.price}, #{item.count},
    14         #{item.returnCount}, #{item.status}, #{item.promotionProductId}, #{item.promotionSubject}, #{item.createdDate},
    15         #{item.createdBy}, #{item.lastUpdatedDate}, #{item.lastUpdatedBy}, #{item.removeFlag}, #{item.weight}, #{item.volume},
    16         #{item.shortName}, #{item.specName}
    17       )
    18     </foreach>
    19   </insert>

    细节方面需自己完善下

  • 相关阅读:
    when you try to reconfigure the BizTalk Server 2006 R2 EDI/AS2 Runtime feature
    Win7中发现的一个好东西
    WebMethod 处理 FlatFile
    BizTalk Http Adapter (BTSHttpReceive.dll) Error
    P1108 低价购买 DP
    Delete a Work Item Field from a Team Project Collection
    MCTS 70512: Unofficial Visual Studio Team Foundation Server 2010, Administration
    WEBGIS模型探讨
    TFS 2010 Red X on Work Items (TF51535)
    WIT: Field Name命名重复
  • 原文地址:https://www.cnblogs.com/180308-new-file/p/8994027.html
Copyright © 2011-2022 走看看