Robert Jaros
02/07/2022, 7:41 PMToshihiro Nakamura
02/08/2022, 12:49 PMRobert Jaros
02/08/2022, 1:34 PMToshihiro Nakamura
02/08/2022, 11:00 PMval sql = "select * from address where street = /*street*/'test'"
val query = QueryDsl.fromTemplate(sql).bind(
object {
val street = "STREET 10"
}
).select { row ->
Address(
row.asInt("address_id")!!,
row.asString("street")!!,
row.asInt("version")!!
)
}
val list: List<Address> = db.runQuery(query)
The above code will issue the following SQL:
select * from address where street = ?
The code in the link may be helpful:
https://github.com/komapper/komapper/blob/main/integration-test-jdbc/src/test/kotlin/integration/jdbc/TemplateTest.ktToshihiro Nakamura
02/08/2022, 11:03 PM