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>
伝播NOT_SUPPORTEDを持つメソッドから呼び出されるネストされたREQUIRED_NEW伝播を持つことは可能ですか?
dumpAllData()で大規模なDB操作(〜100Mb)を実行するため、トランザクションを実行したくありません(そうでない場合は、パフォーマンスの問題になります)。ただし、updateItemメソッド(エンティティの単純な更新のみを行う)でトランザクション(ロールバック/コミット)を実行する必要があります。