首页 > 代码库 > 类和方法上加事务
类和方法上加事务
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); } }
类和方法上加事务
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。