0

So I have a query I need to run like UPDATE entity WHERE id IN (:ids). I know when doing a SELECT I can do something like

val sql = "SELECT * FROM entity WHERE id IN (:ids)";
jdbcTemplate.queryForList(sql, Collections.singletonMap("ids", ids));
Is there any way to accomplish this for an `UPDATE` query where I don't have to just turn my list of ids into a comma seperated string and call it like
val params = ids.joinToString(",")
jdbcTemplate.update(sql, mapOf(Pair("ids", params)))

EDIT: Turns out the second way I listed doesn't even work because it is expecting a Double and gets a string

TovrikTheThird
  • 471
  • 2
  • 7
  • 20

1 Answers1

0

In Java you can do this like this:

String joinedIds = Arrays.stream(tradeListIds).collect(Collectors.joining(", "));
wiomoc
  • 1,069
  • 10
  • 17
  • Hey, thats useful to know. Thanks. Actually doesn't solve my problem though as it expects a double since the db entry is an `INT(11)`. I am using Kotlin and updated my example above (even though it doesn't work) to do it in a more kotlin-y way. – TovrikTheThird Jan 10 '19 at 00:33