我有一个SQL查询,其中有很多占位符“?”,它是动态构建的,我想要放置一个值数组来替换这些占位符。数组的大小每次可能都不同。数组按顺序包含所有参数。
return jdbcTemplate.query(Queries.someQuery,
new Object[] {/* Array must be here */},
new ResultSetExtractor<List<String>>() {
@Override
public List<String> extractData(ResultSet resultSet)
}
});
SQL生成的示例:
for (int j = 0; j < y; j++) {
conditionsBuilder.append("\n and p"+i+".object_id=o.object_id\n" +
" and p"+i+".attr_id =?\n" +
" and p"+i+".value =?\n");
tablesBuilder.append(",patameters p"+i+" ");
i++;
}