use of org.springframework.transaction.support.DefaultTransactionStatus in project molgenis by molgenis.
the class PostgreSqlTransactionManager method doRollback.
@Override
protected void doRollback(DefaultTransactionStatus status) {
MolgenisTransaction transaction = (MolgenisTransaction) status.getTransaction();
if (LOG.isDebugEnabled()) {
LOG.debug("Rollback transaction [{}]", transaction.getId());
}
DefaultTransactionStatus jpaTransactionStatus = new DefaultTransactionStatus(transaction.getDataSourceTransaction(), status.isNewTransaction(), status.isNewSynchronization(), status.isReadOnly(), status.isDebug(), status.getSuspendedResources());
if (!status.isReadOnly()) {
transactionListeners.forEach(j -> j.rollbackTransaction(transaction.getId()));
}
super.doRollback(jpaTransactionStatus);
}
use of org.springframework.transaction.support.DefaultTransactionStatus in project spring-framework by spring-projects.
the class TransactionSupportTests method noExistingTransaction.
@Test
public void noExistingTransaction() {
PlatformTransactionManager tm = new TestTransactionManager(false, true);
DefaultTransactionStatus status1 = (DefaultTransactionStatus) tm.getTransaction(new DefaultTransactionDefinition(TransactionDefinition.PROPAGATION_SUPPORTS));
assertThat(status1.hasTransaction()).as("Must not have transaction").isFalse();
DefaultTransactionStatus status2 = (DefaultTransactionStatus) tm.getTransaction(new DefaultTransactionDefinition(TransactionDefinition.PROPAGATION_REQUIRED));
assertThat(status2.hasTransaction()).as("Must have transaction").isTrue();
assertThat(status2.isNewTransaction()).as("Must be new transaction").isTrue();
assertThatExceptionOfType(IllegalTransactionStateException.class).isThrownBy(() -> tm.getTransaction(new DefaultTransactionDefinition(TransactionDefinition.PROPAGATION_MANDATORY)));
}
Aggregations