java - spring中事务嵌套事务Propagation.REQUIRES_NEW传播行为疑问
阿神
阿神 2017-04-17 17:24:40
0
1
441

有一个问题,spring中事务的注解方式
在service层的一个方法配置事务

@Transactional(value = "edwManager", rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW)
    public String edwDataSync(String xmlJson){
    for (int i = 0; i < 10; i++){
        操作数据库插入A表
    }
    for (int y = 0; y < 10; y++){
        操作数据库插入B表
    }
    }

疑问,事务传播方式如果使用REQUIRES_NEW 这种,那这个方法事务一共起了几个。
A表循环插入了10次,B表也插入了10次

Propagation.REQUIRES_NEW 新建事务,如果当前存在事务,把当前事务挂起。

阿神
阿神

闭关修行中......

reply all(1)
阿神

Your annotation is written on the service, so your service method will be suspended only when other methods that open things execute your service method. Second, what you call in this method should not be a business method, but a dao method. , so you only have one thing.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!