I've just accidentally found this impressive project, I've never even heard about before - https://github.com/komapper/komapper. Definitely worth checking when someone is looking for a Kotlin ORM.
👍🏻 1
👍 10
t
Toshihiro Nakamura
02/08/2022, 12:49 PM
Hi, I'm the author of the project. Thank you for bringing this up. I hope you will try Komapper. I'm looking forward to your feedback.
➕ 2
r
Robert Jaros
02/08/2022, 1:34 PM
Hi, @Toshihiro Nakamura
As the reference docs are unfortunately not in English (yet?), could you please tell me if there is a way to call native SQL queries in komapper?
t
Toshihiro Nakamura
02/08/2022, 11:00 PM
Komapper supports SQL templates. Using this feature, you can write the following:
Copy code
val 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)