Example usage for org.springframework.jdbc.datasource ConnectionHolder isRollbackOnly

List of usage examples for org.springframework.jdbc.datasource ConnectionHolder isRollbackOnly

Introduction

In this page you can find the example usage for org.springframework.jdbc.datasource ConnectionHolder isRollbackOnly.

Prototype

public boolean isRollbackOnly() 

Source Link

Document

Return whether the resource transaction is marked as rollback-only.

Usage

From source file:org.springframework.jdbc.datasource.JdbcTransactionObjectSupport.java

/**
 * This implementation creates a JDBC 3.0 Savepoint and returns it.
 * @see java.sql.Connection#setSavepoint
 *//* ww  w  . j  a va 2 s .co  m*/
@Override
public Object createSavepoint() throws TransactionException {
    ConnectionHolder conHolder = getConnectionHolderForSavepoint();
    try {
        if (!conHolder.supportsSavepoints()) {
            throw new NestedTransactionNotSupportedException(
                    "Cannot create a nested transaction because savepoints are not supported by your JDBC driver");
        }
        if (conHolder.isRollbackOnly()) {
            throw new CannotCreateTransactionException(
                    "Cannot create savepoint for transaction which is already marked as rollback-only");
        }
        return conHolder.createSavepoint();
    } catch (SQLException ex) {
        throw new CannotCreateTransactionException("Could not create JDBC savepoint", ex);
    }
}