Example usage for org.springframework.transaction CannotCreateTransactionException CannotCreateTransactionException

List of usage examples for org.springframework.transaction CannotCreateTransactionException CannotCreateTransactionException

Introduction

In this page you can find the example usage for org.springframework.transaction CannotCreateTransactionException CannotCreateTransactionException.

Prototype

public CannotCreateTransactionException(String msg) 

Source Link

Document

Constructor for CannotCreateTransactionException.

Usage

From source file:org.fcrepo.camel.FcrepoTransactionManager.java

@Override
protected void doBegin(final Object transaction, final TransactionDefinition definition) {
    final FcrepoResponse response;
    final InputStream is = null;
    final String contentType = null;
    final FcrepoTransactionObject tx = (FcrepoTransactionObject) transaction;

    if (tx.getSessionId() == null) {
        try {//from w  w  w .  j a v  a2  s.  com
            response = getClient().post(URI.create(baseUrl + TRANSACTION)).body(is, contentType).perform();
        } catch (final FcrepoOperationFailedException ex) {
            LOGGER.debug("HTTP Operation failed: ", ex);
            throw new CannotCreateTransactionException("Could not create fcrepo transaction");
        }

        if (response != null && response.getLocation() != null) {
            tx.setSessionId(response.getLocation().toString().substring(baseUrl.length() + 1));
        } else {
            throw new CannotCreateTransactionException("Invalid response while creating transaction");
        }
    }
}

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
 *//*from  ww  w. j  a v a2s .  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);
    }
}