@Override public <T> T executeTransaction(TransactionOptions options, TransactionalTask<T> task) throws TransactionException { final TransactionContext context = newTransactionContext(options); context.beginTransaction(); try { final T value = task.execute(context); context.commitTransaction(); return value; } catch (Throwable e) { context.rollbackTransaction(); if (e instanceof TransactionException) { throw (TransactionException) e; } if (e.getCause() instanceof TransactionException) { throw (TransactionException) e.getCause(); } if (e instanceof RuntimeException) { throw (RuntimeException) e; } throw new TransactionException(e); } }
@Override public <T> T executeTransaction(TransactionOptions options, TransactionalTask<T> task) throws TransactionException { final TransactionContext context = newTransactionContext(options); context.beginTransaction(); try { final T value = task.execute(context); context.commitTransaction(); return value; } catch (Throwable e) { context.rollbackTransaction(); if (e instanceof TransactionException) { throw (TransactionException) e; } if (e.getCause() instanceof TransactionException) { throw (TransactionException) e.getCause(); } if (e instanceof RuntimeException) { throw (RuntimeException) e; } throw new TransactionException(e); } }
@Override public <T> T executeTransaction(TransactionOptions options, TransactionalTask<T> task) throws TransactionException { checkNotNull(task, "TransactionalTask is required!"); TransactionContext context = newTransactionContext(options); context.beginTransaction(); try { T value = task.execute(context); context.commitTransaction(); return value; } catch (Throwable e) { context.rollbackTransaction(); if (e instanceof TransactionException) { throw (TransactionException) e; } if (e.getCause() instanceof TransactionException) { throw (TransactionException) e.getCause(); } if (e instanceof RuntimeException) { throw (RuntimeException) e; } throw new TransactionException(e); } }
@Override public <T> T executeTransaction(TransactionOptions options, TransactionalTask<T> task) throws TransactionException { checkNotNull(task, "TransactionalTask is required!"); TransactionContext context = newTransactionContext(options); context.beginTransaction(); try { T value = task.execute(context); context.commitTransaction(); return value; } catch (Throwable e) { context.rollbackTransaction(); if (e instanceof TransactionException) { throw (TransactionException) e; } if (e.getCause() instanceof TransactionException) { throw (TransactionException) e.getCause(); } if (e instanceof RuntimeException) { throw (RuntimeException) e; } throw new TransactionException(e); } }