@Test public void testRollback2() throws Exception { thrown.expect(RuntimeException.class); final Account x = new Account(1, 1000); final Account y = new Account(2, 2000); final Account z = new Account(3, 3000); dao.insert(x); dao.insert(y); dao.insert(z); TransactionTemplate.execute(mango, AbstractDataSourceFactory.DEFULT_NAME, new TransactionAction() { @Override public void doInTransaction(TransactionStatus status) { x.add(50); dao.update(x); TransactionTemplate.execute(mango, AbstractDataSourceFactory.DEFULT_NAME, new TransactionAction() { @Override public void doInTransaction(TransactionStatus status) { TransactionTemplate.execute(mango, AbstractDataSourceFactory.DEFULT_NAME, new TransactionAction() { @Override public void doInTransaction(TransactionStatus status) { z.sub(30); dao.update(z); throw new RuntimeException(); } }); y.sub(20); dao.update(y); } }); } }); assertThat(dao.getAccount(1).getBalance(), equalTo(1000)); assertThat(dao.getAccount(2).getBalance(), equalTo(2000)); assertThat(dao.getAccount(3).getBalance(), equalTo(3000)); }
public static void execute( Mango mango, String dataSourceFactoryName, TransactionIsolationLevel level, TransactionAction action) throws TransactionException { execute(TransactionFactory.newTransaction(mango, dataSourceFactoryName, level), action); }
TransactionTemplate { public static void execute( Mango mango, String dataSourceFactoryName, TransactionIsolationLevel level, TransactionAction action) throws TransactionException { execute(TransactionFactory.newTransaction(mango, dataSourceFactoryName, level), action); } }
TransactionTemplate { public static void execute( Mango mango, String dataSourceFactoryName, TransactionIsolationLevel level, TransactionAction action) throws TransactionException { execute(TransactionFactory.newTransaction(mango, dataSourceFactoryName, level), action); }  }
TransactionTemplate { public static void execute( Mango mango, String dataSourceFactoryName, TransactionIsolationLevel level, TransactionAction action) throws TransactionException { execute(TransactionFactory.newTransaction(mango, dataSourceFactoryName, level), action); }  static void execute(
      Mango mango, String dataSourceFactoryName, TransactionIsolationLevel level,
      TransactionAction action); static void execute(Mango mango, String dataSourceFactoryName, TransactionAction action); static void execute(String dataSourceFactoryName, TransactionIsolationLevel level, TransactionAction action); static void execute(String dataSourceFactoryName, TransactionAction action); static void execute(TransactionIsolationLevel level, TransactionAction action); static void execute(TransactionAction action); }
TransactionTemplate { public static void execute( Mango mango, String dataSourceFactoryName, TransactionIsolationLevel level, TransactionAction action) throws TransactionException { execute(TransactionFactory.newTransaction(mango, dataSourceFactoryName, level), action); }  static void execute(
      Mango mango, String dataSourceFactoryName, TransactionIsolationLevel level,
      TransactionAction action); static void execute(Mango mango, String dataSourceFactoryName, TransactionAction action); static void execute(String dataSourceFactoryName, TransactionIsolationLevel level, TransactionAction action); static void execute(String dataSourceFactoryName, TransactionAction action); static void execute(TransactionIsolationLevel level, TransactionAction action); static void execute(TransactionAction action);  }