我已经在saveFoo方法中启动了新的事务,它调用saveFoo并扩展了该事务。现在,由于其他异步线程更新了Bar表,saveBar引发OptimisticLocking Exception。现在,重试saveBar对我不起作用,我不得不在开始新事务的SaveAll处重试。现在的问题是正确的行为。如何在saveBar重试?
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
@Override
public void saveAll(Foo foo){
saveBar(bar)
}
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
@Override
public void saveBar(Bar bar){
}