ich einen Parameter namens Tags in einer SQL-Anweisung verwenden mag:Frühling SQL-Parameter-Mapping (Array)
SELECT * FROM reply WHERE array[:tags] @> array[2293,2294];
ich die Parameter übergeben und führen Sie die Anweisung über:
MapSqlParameterSource params = new MapSqlParameterSource();
Integer[] a={2293,2294};
params.addValue("tags", Arrays.asList(a));
namedParameterJdbcTemplate.queryForObject(statement, params, String.class);
Aber es den Fehler wirft:
01:class org.springframework.dao.InvalidDataAccessApiUsageException No value supplied for the SQL parameter 'tags]': No value registered for key 'tags]'
Wenn ich die Aussage zu ändern
SELECT * FROM reply WHERE '{:tags}' @> array[2293,2294];
Es wirft den Fehler:
class org.springframework.dao.DataIntegrityViolationException PreparedStatementCallback; SQL [SELECT * FROM reply WHERE '{:tags}' @> array[2293,2294]; ERROR: invalid input syntax for integer: ":tags" Position: 72; nested exception is org.postgresql.util.PSQLException: ERROR: invalid input syntax for integer: ":tags" Position: 72
Wenn ich die Aussage zu ändern:
SELECT * FROM reply WHERE (:tags) @> array[2293,2294];
Es führt den Fehler: von
class org.springframework.jdbc.BadSqlGrammarException PreparedStatementCallback; bad SQL grammar [SELECT * FROM reply WHERE (?, ?) @> array[2293,2294]; nested exception is org.postgresql.util.PSQLException: ERROR: operator does not exist: record @> integer[] Hint: No operator matches the given name and argument type(s). You might need to add explicit type casts. Position: 81
Sieht aus, als gäbe es ein ähnliches Problem: http://stackoverflow.com/questions/31925109/how-to-pass-an-array-parameter-using-namedparameterjdbctemplate-to-a-function-wh –