Spring transaction by connecting to multiple databases

前端 未结 1 1391
被撕碎了的回忆
被撕碎了的回忆 2021-01-29 05:21

I am trying to work on a small program where I can connect to multiple databases using Spring and trying to use Spring transactions by deploying my web-application on weblogic s

1条回答
  •  误落风尘
    2021-01-29 06:15

    Try adding below in spring-config.xml:

    
    
    

    and changing @Transactional in your CommonEmployeeService with @Transactional(rollbackFor=Exception.class, propagation=Propagation.REQUIRED) as below

    @Service
    public class CommonEmployeeService {
    
        @Autowired
        EmployeeDetailsService detailsService;
    
        @Autowired
        EmployeeService service;
    
    @Transactional(rollbackFor=Exception.class, propagation=Propagation.REQUIRED)
        public boolean insert(Employee e, EmployeeDetails details) {
            service.insert(e);
            detailsService.insert(details);
            return true;
        }
    }
    

    0 讨论(0)
提交回复
热议问题