public class BusinessService { //spring bean
public dumpAllData(List){
/* Complicated DB operation here
* We dont want to be in transaction now (because of performance issues)
*/
for(...){ //iterating through whole list
**updateItem(item);**
}
}
public updateItem(Entity e){
//saves entity into DB
//we want to be in transaction now
}
}
弹簧配置:
<tx:advice id="txAdvice" transaction-manager="wsTransactionManager">
<tx:attributes>
<tx:method name="dumpAllData" propagation="NOT_SUPPORTED" />
<tx:method name="updateItem" propagation="REQUIRES_NEW" />
</tx:attributes>
</tx:advice>
是否可能有嵌套的 REQUIRED_NEW 传播,该传播将从具有传播 NOT_SUPPORTED 的方法中调用?
问题是我们在 dumpAllData() 中运行了一个广泛的数据库操作(~ 100Mb),所以我们不想在事务中(否则这将是性能问题)。但是我们希望在 updateItem 方法(我们只做简单的实体更新)中的事务(回滚/提交)。