Example usage for org.springframework.transaction TransactionUsageException TransactionUsageException

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

Introduction

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

Prototype

public TransactionUsageException(String msg) 

Source Link

Document

Constructor for TransactionUsageException.

Usage

From source file:org.topazproject.otm.spring.OtmTransactionManager.java

@Override
public void doCommit(DefaultTransactionStatus status) throws TransactionException {
    TransactionObject txObj = (TransactionObject) status.getTransaction();

    Transaction tx = txObj.getSession().getTransaction();
    if (tx == null)
        throw new TransactionUsageException("no transaction active");

    try {//from w ww .  j  av a  2  s.c  om
        tx.commit();
    } catch (OtmException oe) {
        throw new TransactionSystemException("error committing transaction", oe);
    } finally {
        if (txObj.savedFlushMode != null)
            txObj.getSession().setFlushMode(txObj.savedFlushMode);
    }
}

From source file:org.topazproject.otm.spring.OtmTransactionManager.java

@Override
public void doRollback(DefaultTransactionStatus status) throws TransactionException {
    TransactionObject txObj = (TransactionObject) status.getTransaction();

    Transaction tx = txObj.getSession().getTransaction();
    if (tx == null)
        throw new TransactionUsageException("no transaction active");

    try {/*from www .jav a2  s  .  c om*/
        tx.rollback();
    } catch (OtmException oe) {
        throw new TransactionSystemException("error rolling back transaction", oe);
    } finally {
        if (clearSessionOnRB)
            txObj.getSession().clear();
        if (txObj.savedFlushMode != null)
            txObj.getSession().setFlushMode(txObj.savedFlushMode);
    }
}

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

protected ConnectionHolder getConnectionHolderForSavepoint() throws TransactionException {
    if (!isSavepointAllowed()) {
        throw new NestedTransactionNotSupportedException(
                "Transaction manager does not allow nested transactions");
    }/*  w w w  .  ja  v  a  2 s  .  co  m*/
    if (!hasConnectionHolder()) {
        throw new TransactionUsageException(
                "Cannot create nested transaction when not exposing a JDBC transaction");
    }
    return getConnectionHolder();
}