1. 程式人生 > >類和方法上加事務

類和方法上加事務

入庫 temp spring ise work order -1 oid mes

package com.yundaex.wms.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; @Component @Transactional(propagation = Propagation.REQUIRED, rollbackFor = { Exception.class }) public class TestAop { @Autowired private JdbcTemplate jdbcTemplate; @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true
) public void test() { String sql = " select count(1) from riv_inbound_notice_h where inh_owner_no = ‘425-1‘ "; System.out.println(+jdbcTemplate.queryForObject(sql, Integer.class)); } @Transactional(propagation = Propagation.REQUIRED, rollbackFor = { Exception.class })
public void addData(IWMSC_Order_inboundData param){ IWMSC_Order_in_headerData header = param.getHeader(); List<IWMSC_Order_in_itemData> items = param.getItems(); if (header==null||!CommonMethodHelper.isCollectionValid(items)) { YDAssert.isErrData("入庫通知單單頭或明細為空"); } WMSC_busi_inboundPO inh = new WMSC_busi_inboundPO(); List<WMSC_busi_inbound_planPO> inls = new ArrayList<WMSC_busi_inbound_planPO>(); List<WMSC_stock_matPO> stock_matPOs = new ArrayList<WMSC_stock_matPO>(); // 業務單流水號 String doc_id = SerialNumberUtil.getWholeSerialNumber(WMSCConstant.C_ORDER_IN); Timestamp d = new Timestamp(System.currentTimeMillis()); getInboundPO(doc_id,d,header,inh); getPlanPOs(doc_id,d,header,items,inls,stock_matPOs); //保存數據 save(inh,inls,stock_matPOs); } }

類和方法上加事務