/** * Convert a Map of named parameter values to a corresponding array. * * @param parsedSql the parsed SQL statement * @param paramSource the source for named parameters * @return the array of values */ public static Object[] buildValueArray(ParsedSql parsedSql, Map<String, Object> paramSource) throws SQLException { Object[] valueArray = new Object[parsedSql.getTotalParameterCount()]; if (parsedSql.getNamedParameterCount() > 0 && parsedSql.getUnnamedParameterCount() > 0) { throw new SQLException("You can't mix named and traditional ? placeholders."); } List<String> paramNames = parsedSql.getParameterNames(); for (int i = 0; i < paramNames.size(); i++) { String paramName = paramNames.get(i); valueArray[i] = paramSource.get(paramName); } return valueArray; }