Code:
RuleBasedTransactionAttribute rules = new RuleBasedTransactionAttribute();
rules.getRollbackRules().add(new NoRollbackRuleAttribute(RuntimeException.class));
TransactionTemplate transactionTemplate = new TransactionTemplate(transactionManager,rules);
transactionTemplate.execute(new TransactionCallbackWithoutResult() {
@Override
protected void doInTransactionWithoutResult(TransactionStatus status) {
if(true) throw new RuntimeException();
}
});
Is there anyone who can explain the logic behind such implementation? I think it would be nice to give custom rollback rules to TransactionTemplate to change rollback logic on exception occurence. Or am I simply wrong?