【发布时间】:2012-01-09 13:58:43
【问题描述】:
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 方法中的事务(回滚/提交)中(我们只是简单地更新实体)。
【问题讨论】:
标签: spring nested commit spring-transactions propagation