LoginSignup
1
2

More than 5 years have passed since last update.

メモ - Spring - 入れ子になった @Transactional の内側でローバック対象の例外が発生してもローバックさせない方法

Posted at

PlatformTransactionManager の globalRollbackOnParticipationFailure を false に設定すればよい(が、@Transactional が付いている単位で整合性のあるデータとしているともうので、このフラグをfalseにするということは、中途半端な状態でのコミットを許容するということに繋がる)

@Configuration
public class TransactionConfiguration {
    @Autowired
    private DataSource dataSource;

    @Bean
    public PlatformTransactionManager transactionManager() {
        DataSourceTransactionManager transactionManager = new DataSourceTransactionManager(dataSource);
        transactionManager.setGlobalRollbackOnParticipationFailure(false);
        return transactionManager;
    }
}
1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2