|
|
how to pass parameter for sql in
= this.jdbcTemplate.query(quot;select count(0) from t_actors where first_name in () quot;, new Object[]{quot;Joe, jeequot;})
Easy, use the named parameter support of the SimpleJdbcTempate (Spring 2.5):Code: List l = simpleJdbcTemplate.queryForList(quot;select count(0) from t_actors where first_name in (:names)quot;,Collections.singletonMap(quot;namesquot;, Arrays.asList(new Object[]{quot;Joequot;, quot;jeequot;})));
Just keep the number of entries in the list reasonable - each database impose different limits. NamedParameterJdbcTemplate (Spring 2.0) has similar feature as well. |
|