use of org.springframework.transaction.TransactionSystemException in project spring-framework by spring-projects.
the class DataSourceTransactionManagerTests method testTransactionWithExceptionOnCommitAndRollbackOnCommitFailure.
@Test
public void testTransactionWithExceptionOnCommitAndRollbackOnCommitFailure() throws Exception {
willThrow(new SQLException("Cannot commit")).given(con).commit();
tm.setRollbackOnCommitFailure(true);
TransactionTemplate tt = new TransactionTemplate(tm);
try {
tt.execute(new TransactionCallbackWithoutResult() {
@Override
protected void doInTransactionWithoutResult(TransactionStatus status) {
// something transactional
}
});
fail("Should have thrown TransactionSystemException");
} catch (TransactionSystemException ex) {
// expected
}
assertTrue("Hasn't thread connection", !TransactionSynchronizationManager.hasResource(ds));
verify(con).rollback();
verify(con).close();
}
use of org.springframework.transaction.TransactionSystemException in project ignite by apache.
the class SpringTransactionManager method doCommit.
/**
* {@inheritDoc}
*/
@Override
protected void doCommit(DefaultTransactionStatus status) throws TransactionException {
IgniteTransactionObject txObj = (IgniteTransactionObject) status.getTransaction();
Transaction tx = txObj.getTransactionHolder().getTransaction();
if (status.isDebug() && log.isDebugEnabled())
log.debug("Committing Ignite transaction: " + tx);
try {
tx.commit();
} catch (IgniteException e) {
throw new TransactionSystemException("Could not commit Ignite transaction", e);
}
}
Aggregations