@Override public <ReturnType> ReturnType inTransaction(final Handle handle, final TransactionCallback<ReturnType> callback) { int retriesRemaining = configuration.maxRetries; while (true) { try { return getDelegate().inTransaction(handle, callback); } catch (Exception e) { if (!isSqlState(configuration.serializationFailureSqlStates, e) || --retriesRemaining <= 0) { if (e instanceof RuntimeException) { throw (RuntimeException) e; } throw new TransactionFailedException(e); } if (e instanceof SQLException) { final String sqlState = ((SQLException) e).getSQLState(); log.warn("Restarting transaction due to SQLState {}, retries remaining {}", sqlState, retriesRemaining); } else { log.warn("Restarting transaction due to {}, retries remaining {}", e.toString(), retriesRemaining); } } } }
@Override public <ReturnType> ReturnType inTransaction(final Handle handle, final TransactionCallback<ReturnType> callback) { int retriesRemaining = configuration.maxRetries; while (true) { try { return getDelegate().inTransaction(handle, callback); } catch (Exception e) { if (!isSqlState(configuration.serializationFailureSqlStates, e) || --retriesRemaining <= 0) { if (e instanceof RuntimeException) { throw (RuntimeException) e; } throw new TransactionFailedException(e); } if (e instanceof SQLException) { final String sqlState = ((SQLException) e).getSQLState(); log.warn("Restarting transaction due to SQLState {}, retries remaining {}", sqlState, retriesRemaining); } else { log.warn("Restarting transaction due to {}, retries remaining {}", e.toString(), retriesRemaining); } } } }
throw new TransactionFailedException( "Can't validate a transaction before commit", ex); throw new TransactionFailedException( "Trying to commit a transaction that is already aborted. " + "Because current transaction is aborted, commands including " +
@Override public <ReturnType> ReturnType inTransaction(Handle handle, TransactionCallback<ReturnType> callback) { int retriesRemaining = configuration.maxRetries; while (true) { try { return getDelegate().inTransaction(handle, callback); } catch (Exception e) { if (!isSqlState(configuration.serializationFailureSqlStates, e) || --retriesRemaining <= 0) { if (e instanceof RuntimeException) { throw (RuntimeException) e; } throw new TransactionFailedException(e); } if (e instanceof SQLException) { final String sqlState = ((SQLException) e).getSQLState(); log.warn("Restarting transaction due to SQLState {}, retries remaining {}", sqlState, retriesRemaining); } else { log.warn("Restarting transaction due to {}, retries remaining {}", e.toString(), retriesRemaining); } } } }
@Override public <ReturnType> ReturnType inTransaction(final Handle handle, final TransactionCallback<ReturnType> callback) { int retriesRemaining = configuration.maxRetries; while (true) { try { return getDelegate().inTransaction(handle, callback); } catch (final Exception e) { if (!isSqlState(configuration.serializationFailureSqlStates, e) || --retriesRemaining <= 0) { if (e instanceof RuntimeException) { throw (RuntimeException) e; } throw new TransactionFailedException(e); } if (e instanceof SQLException) { final String sqlState = ((SQLException) e).getSQLState(); log.warn("Restarting transaction due to SQLState {}, retries remaining {}", sqlState, retriesRemaining); } else { log.warn("Restarting transaction due to {}, retries remaining {}", e.toString(), retriesRemaining); } } } }
@Override public ParamServerClientConnection getConnection() { Handle handle = dbi.open(); try { handle.getConnection().setAutoCommit(false); } catch (SQLException ex) { throw new TransactionFailedException("Failed to set auto commit: " + false, ex); } handle.begin(); return new PostgresqlServerClientConnection(handle); }
throw new TransactionFailedException("Transaction failed do to exception being thrown " + "from within the callback. See cause " + "for the original exception.", e); throw new TransactionFailedException("Transaction failed due to transaction status being set " + "to rollback only.");
throw new TransactionFailedException("Transaction failed do to exception being thrown " + "from within the callback. See cause " + "for the original exception.", e); throw new TransactionFailedException("Transaction failed due to transaction status being set " + "to rollback only.");
public <T, E1 extends Exception, E2 extends Exception, E3 extends Exception> T transaction( TransactionActionWithExceptions<T, D, E1, E2, E3> action, Class<E1> exClass1, Class<E2> exClass2, Class<E3> exClass3) throws E1, E2, E3 { try { Handle handle = transactionManager.getHandle(configMapper); return action.call(handle, handle.attach(daoIface)); } catch (Exception ex) { Throwables.propagateIfInstanceOf(ex, exClass1); Throwables.propagateIfInstanceOf(ex, exClass2); Throwables.propagateIfInstanceOf(ex, exClass3); Throwables.propagateIfPossible(ex); throw new TransactionFailedException( "Transaction failed due to exception being thrown " + "from within the callback. See cause " + "for the original exception.", ex); } }
throw new TransactionFailedException("Failed to set auto commit: " + autoAutoCommit, ex);