Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

436
Views
How to execute ANY() SQL in Spring jdbcTemplate?

I want to execute the query

"SELECT sd.id, sd.word, sd.desc FROM word_data sd WHERE sd.word = ANY (VALUES :words)"

Prepare arguments

for(String element : key){
    listElement.add("('" + element + "')");
}

String finalString = StringUtils.join(listElement.iterator(), ",");

Map<String, Object> arg = new HashMap<>();
arg.put("words", finalString);

Execute queries

namedParameterJdbcTemplate.query(sql, arg,
            (rs, rowNum) -> new Word(rs.getInt("id"), rs.getString("word"), rs.getString("desc")));

Exception is returned

org.postgresql.util.PSQLException: ERROR: Syntax error (approximate position: "$1")

How to correctly fill in the arguments for such a query? When the arguments were inserted manually and the query was executed successfully.

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!