title: How Do I Pass an Array of Strings Query String with the JdbcTemplate Query For Object Function?
body: <p>I would like to pass an array of strings to a stored procedure with jdbcTemplate and am having trouble doing so. This is the query:</p>
  
  <pre><code>"SELECT * from stored_procedure(?::text[])"
  </code></pre>
  
  <p>This is how I am calling the stored procedure with the jdbcTemplate (where notes is a List):</p>
  
  <pre><code>jdbcTemplate.queryForObject(sql, Long.class, notes == null ? null : notes.toArray());
  </code></pre>
  
  <p>This is the error I get:</p>
  
  <pre><code>PreparedStatementCallback; bad SQL grammar [SELECT * from stored_procedure(?::text[])]; nested exception is org.postgresql.util.PSQLException: Can't infer the SQL type to use for an instance of [Ljava.lang.Object;. Use setObject() with an explicit Types value to specify the type to use.
  </code></pre>
  
  <p>I haven't found anything online for fixing this problem.</p>