Я настраиваю SqlParamSource как
Код: Выделить всё
private SqlParameterSource getSqlParamsForPollingLogUpdateWithMerge(int[] ids){
final MapSqlParameterSource params = new MapSqlParameterSource();
try{
SQLServerDataTable table = new SQLServerDataTable();
table.addColumnMetadata("id",java.sql.Types.INTEGER);
table.setTvpName("dbo.idtable");
for (int id : ids) {
table.addRow(id);
}
params.addValue("idtable", table);
return params;
}catch (Exception ex){
throw new RuntimeException(ex);
}
}
Код: Выделить всё
String sql= "create type dbo.idtable AS TABLE (id INT);" +
"MERGE INTO table1 AS tgt" +
"USING :idtable as src\n" +
"ON tgt.id=src.id" +
"WHEN MATCHED THEN" +
"UPDATE SET ..." +
"WHEN NOT MATCHED THEN" +
"INSERT ;";
Подробнее здесь: https://stackoverflow.com/questions/790 ... -statement