UserGoodsOrderService implements IUserGoodsOrderService { @Override public synchronized void batchUpdate(Set<UserGoodsOrderPo> set) throws Exception{ if(null != set){ List<UserGoodsOrderPo> UserGoodsOrderPos = new ArrayList<UserGoodsOrderPo>(); for (UserGoodsOrderPo userGoodsOrder : set) { if(StringUtils.isNotBlank(userGoodsOrder.getShopCartGoodsCookieId())){ logger.info("Update action，BusinessOperationType"+ userGoodsOrder.getBusinessOperationType()); UserGoodsOrderPo po = userGoodsOrderDao.findBy(userGoodsOrder.getShopCartGoodsCookieId()); if(null != po){ logger.info("Update before UserGoodsOrderPo:"+po); convertUpdateUserGoodsOrder(userGoodsOrder, po); logger.info("Updata UserGoodsOrderPo:"+po); UserGoodsOrderPos.add(po); } else{ logger.warn("WARN...! " + userGoodsOrder); userGoodsOrderDao.save(userGoodsOrder); } } else{ logger.warn("Update UserGoodsOrderPo Entity then GoodsCookieId and ShopCartCookieId is not null."); } } logger.info("正在 Update "+ UserGoodsOrderPos.size() +" UserGoodsOrderPo"); try { userGoodsOrderDao.save(UserGoodsOrderPos); } catch (IllegalArgumentException e) { logger.error("批量更新失败，失败原因："+e.getMessage(),e); } } }  @Override void batchInsert(Set<UserGoodsOrderPo> set); @Override synchronized void batchUpdate(Set<UserGoodsOrderPo> set); @Override synchronized void processingData(Set<UserGoodsOrderDetailVo> userGoodsOrderDetailVos);  }
@Test public void testBatchUpdate() throws Exception{ userGoodsOrders = new LinkedHashSet<UserGoodsOrderPo>(); for(int i=0; i<=1;i++){ UserGoodsOrderPo userGoodsOrderPo = new UserGoodsOrderPo(); userGoodsOrderPo.setBusinessOperationType("3"); userGoodsOrderPo.setShopCartCookieId("28bccde8-ce2c-490f-a06a-7158654dfc8f"); userGoodsOrderPo.setShopCartGoodsCookieId("2C72B63CFC804B259DF83B4C927CF1F1"); userGoodsOrderPo.setGoodsName("尊享I型"); userGoodsOrderPo.setHyCode("hy439009"); userGoodsOrders.add(userGoodsOrderPo); } userGoodsOrderService.batchUpdate(userGoodsOrders); }