Spring嵌套事务​​通用示例

时间:2016-04-19 05:38:44

标签: java spring hibernate transactions propagation

任何机构都可以提供一些见解..

我一直很难过,而且经历过 spring @Transactional(Propagation Nested)

我一直在网上和这里搜索,但无法找到关于此的特定类型的任何通用示例..

    @Transactional(required)
    mtdOne(User userObj1, User userObj2)
    {
    someBean.mtdtwo( userObj1);
    someBean.mtdThree(userObj2);

    }

@transactional(nested)
mtdTwo(userObj1)
 {
//calling dao and insert data into DATABASE
daoObj.save(userObj1);
//this data must not be rolled back, 
//  even though exception thrown in next method
}

@transactional(required)
mtdThree(userObj2)
 {
//calling dao second time and insert data into DATABASE
daoObj.save(userObj2);


/////Some Exception thrown here

}

所以我想将methodTwo数据保存到DB中,不能回滚 即使在下一个方法中抛出异常..

我希望使用交易(嵌套)

来实现此目的

请给我任何建议..

0 个答案:

没有答案