Example usage for org.springframework.transaction.support SimpleTransactionStatus isRollbackOnly

List of usage examples for org.springframework.transaction.support SimpleTransactionStatus isRollbackOnly

Introduction

In this page you can find the example usage for org.springframework.transaction.support SimpleTransactionStatus isRollbackOnly.

Prototype

@Override
public boolean isRollbackOnly() 

Source Link

Document

Determine the rollback-only flag via checking both the local rollback-only flag of this TransactionStatus and the global rollback-only flag of the underlying transaction, if any.

Usage

From source file:org.dalesbred.integration.spring.SpringTransactionContextTest.java

@Test
public void rollingBackDelegatesToOriginalContexts() throws SQLException {
    try (Connection connection = TestDatabaseProvider.createInMemoryHSQLDataSource().getConnection()) {
        SimpleTransactionStatus status = new SimpleTransactionStatus();
        SpringTransactionContext context = new SpringTransactionContext(status, connection);

        assertThat(context.getConnection(), is(connection));

        assertThat(context.isRollbackOnly(), is(false));
        assertThat(status.isRollbackOnly(), is(false));
        context.setRollbackOnly();/*  w  w  w .  ja  v  a2  s  . c o m*/
        assertThat(context.isRollbackOnly(), is(true));
        assertThat(status.isRollbackOnly(), is(true));
    }
}