Example usage for org.springframework.transaction NoTransactionException NoTransactionException

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

Introduction

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

Prototype

public NoTransactionException(String msg) 

Source Link

Document

Constructor for NoTransactionException.

Usage

From source file:org.grails.datastore.mapping.transactions.TransactionUtils.java

public static Transaction<?> currentTransaction(Datastore datastore) {
    final Transaction<?> transaction = getTransaction(datastore);
    if (transaction == null) {
        throw new NoTransactionException("No transaction started.");
    }//from w w w.j  a va2  s.  co  m
    return transaction;
}

From source file:org.grails.datastore.mapping.core.AbstractSession.java

public Transaction getTransaction() {
    if (transaction == null) {
        throw new NoTransactionException("Transaction not started. Call beginTransaction() first");
    }//from ww  w. j  a  v  a  2 s  .c o m
    return transaction;
}

From source file:org.grails.datastore.mapping.redis.util.JedisTemplate.java

public Object[] exec() {
    return (Object[]) execute(new RedisCallback<Jedis>() {
        public Object doInRedis(Jedis redis) {
            if (transaction != null) {
                List<Object> results = transaction.exec();
                try {
                    return results.toArray(new Object[results.size()]);
                } finally {
                    transaction = null;/* ww w  .j av  a  2 s  .  c o m*/
                }
            }
            throw new NoTransactionException("No transaction started. Call multi() first!");
        }
    });
}

From source file:org.springframework.transaction.interceptor.TransactionAspectSupport.java

/**
 * Return the transaction status of the current method invocation.
 * Mainly intended for code that wants to set the current transaction
 * rollback-only but not throw an application exception.
 * @throws NoTransactionException if the transaction info cannot be found,
 * because the method was invoked outside an AOP invocation context
 *///ww w . j a  v a 2 s .c o  m
public static TransactionStatus currentTransactionStatus() throws NoTransactionException {
    TransactionInfo info = currentTransactionInfo();
    if (info == null || info.transactionStatus == null) {
        throw new NoTransactionException("No transaction aspect-managed TransactionStatus in scope");
    }
    return info.transactionStatus;
}

From source file:org.springframework.transaction.interceptor.TransactionInterceptor.java

/**
 * Return the transaction status of the current method invocation.
 * Mainly intended for code that wants to set the current transaction
 * rollback-only but not throw an application exception.
 * @throws NoTransactionException//www . ja v  a  2s  .  co  m
 * if the invocation cannot be found, because the method was invoked
 * outside an AOP invocation context
 */
public static TransactionStatus currentTransactionStatus() throws AspectException {
    TransactionStatus status = (TransactionStatus) currentTransactionStatus.get();
    if (status == null) {
        throw new NoTransactionException("No TransactionInterceptor-managed TransactionStatus in scope");
    }
    return status;
}