I've just accidentally found this impressive proje...
# server
r
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
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
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
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)
The above code will issue the following SQL:
Copy code
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.kt
The English version of the documentation is currently under construction and will be available in a month or two. Questions are always welcome.😃
👍 1