In our last episode ( • jOOQ vs Exposed - Kotlin database acc... ), Lukas Eder from jOOQ - the Java Object Oriented Query library (https://www.jooq.org/), left us with working code, but no way of delimiting transactions. In our Exposed implementation we use Kotlin context receivers to ensure that database access code is running inside a transaction, so we would like to do the same here.
jOOQ allows us to take one of its DSL objects, start a transaction on it, and pass that around. So we use that facility, carefully managing scope functions to make sure that transactions are completed. We also find a way to write a test that shows what information is visible between transactions.
This is part 70 of an exploration of where a Test Driven Development implementation of the Gilded Rose stock control system might take us in Kotlin. You can see the whole series as a playlist
• All Gilded Rose Episodes
and the code on GitHub
https://github.com/dmcg/gilded-rose-tdd
Other database-specific episodes are collected in a playlist • Database Access
If you like this, you’ll probably like my book Java to Kotlin, A Refactoring Guidebook
(http://java-to-kotlin.dev). It's about far more than just the syntax differences between the languages - it shows how to upgrade your thinking to a more functional style.
I have some free time between producing videos and working for team Gilded Rose. If you like these videos I'd like to work with you - please get in touch - [email protected]
Смотрите видео jOOQ Transactions with Kotlin Context Receivers онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь Pairing with Duncan 21 Апрель 2023, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 1,188 раз и оно понравилось 38 людям.