Example usage for org.springframework.transaction.interceptor RuleBasedTransactionAttribute rollbackOn

List of usage examples for org.springframework.transaction.interceptor RuleBasedTransactionAttribute rollbackOn

Introduction

In this page you can find the example usage for org.springframework.transaction.interceptor RuleBasedTransactionAttribute rollbackOn.

Prototype

@Override
public boolean rollbackOn(Throwable ex) 

Source Link

Document

Winning rule is the shallowest rule (that is, the closest in the inheritance hierarchy to the exception).

Usage

From source file:org.springframework.batch.core.step.item.FaultTolerantStepFactoryBeanRollbackTests.java

@Test
public void testNonDefaultRollbackRules() throws Exception {
    TransactionAttributeEditor editor = new TransactionAttributeEditor();
    editor.setAsText("+RuntimeException,+SkippableException");
    RuleBasedTransactionAttribute attr = (RuleBasedTransactionAttribute) editor.getValue();
    attr.getRollbackRules().add(new RollbackRuleAttribute(Exception.class));
    assertTrue(attr.rollbackOn(new Exception("")));
    assertFalse(attr.rollbackOn(new RuntimeException("")));
    assertFalse(attr.rollbackOn(new SkippableException("")));
}