dan*_*rba 7 java spring transactions isolation
我有以下代码:
@Service
public class MyService implements IMyService {
@Inject
IAnotherService anotherService;
// injects go here
// some code
@Transactional(isolation=Isolation.SERIALIZABLE)
public Result myMethod() {
// stuff done here
return this.myPrivateMethod()
}
private Result myPrivateMethod() {
// stuff done here
// multiple DAO SAVE of anObject
anotherService.processSomething(anObject);
return result;
}
}
@Service
public class AnotherService implements IAnotherService {
// injections here
// other stuff
@Transactional(isolation=SERIALIZABLE)
public Result processSomething(Object anObject) {
// some code here
// multiple dao save
// manipulation of anObject
dao.save(anObject);
}
}
Run Code Online (Sandbox Code Playgroud)
@Transactional行为是否会传播到 myPrivateMethod 即使它是私有的?。Runtime Exception发生在processSomething(),并processSomething从 调用myPrivateMethod,将myPrivateMethod并myMethod执行回滚?。@Service?如何在@Transactional上下文中的公共服务方法中提取方法并调用多个私有方法?isolation=Isolation.SERIALIZABLE选择一个很好的替代synchronized方法?我知道这已经得到了回答,但我仍然有疑问。
| 归档时间: |
|
| 查看次数: |
4754 次 |
| 最近记录: |