i already asked that in <#C0922A726|general> but t...
# server
t
i already asked that in #general but think this channel might be better suited: I was thinking about replacing spring completely with ktor and other tools. As most things seem to be more or less easily replaceable i wasa wondering how to manage transactions in such a case. How do other people address this issue? While there are plenty examples of how to do programmatic transactions with r2dbc or exposed they all are very simplistic and only show how to use it in the data access layer. but of course we actually need to handle it on service layer so the transaction spans over multiple db queries. What tools are there to abstract the transaction handling?
c
maybe #ktor is even better suited for that question. If you use ktor it needs to be somehow integrated into ktor.
I think there is no ready made solution yet, but you could just handle it manually like it suits your application and then at some later point extract it to a ktor feature
t
i really dont think that ktor is the right place as this problem occurs with any server abstractions
v
I use jdbi.org. I love that it's not abstracted too much, but it still comes with mapping, declarative API, etc. I wrapped it with Kotlin, so I can actually do something like:
Copy code
val transformedUsers = dao.query {  db ->
  db.getUsers().filter { .. }.map { .. }
}
The
dao.query { ... }
block is a transaction with proper exception handling, rollbacks and commits. For REST API, it's more than enough. With custom mapping and other features, you can easily extend it.