简体   繁体   English

Spring 事务从 NOT_SUPPORTED 到 REQUIRES_NEW 的传播

[英]Spring Transaction Propagation from NOT_SUPPORTED to REQUIRES_NEW

I'm working on refactoring a module with an initial method annotated with @Transactional(propagation = Propagation.NOT_SUPPORTED) and this method invokes another method that has the annotation @Transactional(propagation = Propagation.REQUIRES_NEW) .我正在重构一个带有@Transactional(propagation = Propagation.NOT_SUPPORTED)注释的初始方法的模块,该方法调用另一个具有注释@Transactional(propagation = Propagation.REQUIRES_NEW)

My question is, since the initial method is not creating a new transaction, the invoked method will create a new transaction?我的问题是,由于初始方法不是创建新事务,调用的方法会创建新事务吗?

Yes, the invoked method will create and run in a new transaction.是的,调用的方法将在新事务中创建并运行。

REQUIRES_NEW will always create a new transaction irrespective of transactional mode of caller method (even if caller already created a transaction). REQUIRES_NEW 将始终创建一个新事务,而不管调用者方法的事务模式如何(即使调用者已经创建了一个事务)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM