docs: public static <T> T callInTransaction(final DatabaseConnection connection, boolean saved,
  			final DatabaseType databaseType, final Callable<T> callable) throws SQLException {
  
  		boolean restoreAutoCommit = false;
  		TransactionLevel levelCount = transactionLevelThreadLocal.get();
  		try {
  			boolean hasSavePoint = false;
  			Savepoint savePoint = null;
  			if (saved || databaseType.isNestedSavePointsSupported()) {
  				if (connection.isAutoCommitSupported()) {
  					if (connection.isAutoCommit()) {
  						// disable auto-commit mode if supported and enabled at start
  						connection.setAutoCommit(false);
  						restoreAutoCommit = true;
  						logger.trace("had to set auto-commit to false");
  					}
  				}
  				savePoint = connection.setSavePoint(SAVE_POINT_PREFIX + savePointCounter.incrementAndGet());
  				if (savePoint == null) {
  					logger.trace("started savePoint transaction");
  				} else {
  					logger.trace("started savePoint transaction {}", savePoint.getSavepointName());
  				}
  				hasSavePoint = true;
  			}
  			try {
  				levelCount.incrementAndGet();
  				T result = callable.call();
  				int level = levelCount.decrementAndGet();
  				if (level <= 0) {
  					transactionLevelThreadLocal.remove();
  					levelCount = null;
  				}
  				if (hasSavePoint) {
  					// only commit if we have reached the end of our transaction stack
  					if (level <= 0) {
  						commit(connection, savePoint);
  					} else {
  						// otherwise we just release the savepoint
  						release(connection, savePoint);
  					}
  				}
  				return result;
  			} catch (Exception e) {
  				if (levelCount != null && levelCount.decrementAndGet() <= 0) {
  					transactionLevelThreadLocal.remove();
  				}
  				if (hasSavePoint) {
  					try {
  						rollBack(connection, savePoint);
  					} catch (SQLException e2) {
  						logger.error(e, "after commit exception, rolling back to save-point also threw exception");
  						// we continue to throw the commit exception
  					}
  				}
  				if (e instanceof SQLException) {
  					throw (SQLException) e;
  				} else {
  					throw SqlExceptionUtil.create("Transaction callable threw non-SQL exception", e);
  				}
  			}
  		} finally {
  			if (restoreAutoCommit) {
  				// try to restore if we are in auto-commit mode
  				connection.setAutoCommit(true);
  				logger.trace("restored auto-commit to true");
  			}
  		}
  	}