我想执行查询
"SELECT sd.id, sd.word, sd.desc FROM word_data sd WHERE sd.word = ANY (VALUES :words)"
准备参数
for(String element : key){
listElement.add("('" + element + "')");
}
String finalString = StringUtils.join(listElement.iterator(), ",");
Map<String, Object> arg = new HashMap<>();
arg.put("words", finalString);
执行查询
namedParameterJdbcTemplate.query(sql, arg,
(rs, rowNum) -> new Word(rs.getInt("id"), rs.getString("word"), rs.getString("desc")));
返回异常
org.postgresql.util.PSQLException: ERROR: Syntax error (approximate position: "$1")
如何正确填写此类查询的参数?手动插入参数并成功执行查询时。