0:00 / 0:00
#jooq#contextreceivers#transactions
jOOQ Transactions with Kotlin Context Receivers
Pairing with Duncan
4.5K subscribers • 15 videos on Hallway
- Recommended by 1 person: 1 in engineering communities.
- Linked in the descriptiondmcg/gilded-rose-tdd
- May be out of date. The tools, versions or practices it shows have likely moved on.
Intermediate. Assumes working knowledge.
1.4K views3 years ago1 recommendation
Databases and dataProgramming languagesKotlinPostgresSQL
Duncan McGregor demonstrates how to use Kotlin context receivers to manage database transactions cleanly with jOOQ.
In our last episode (youtu.be/6Ji9yKnZ3D8), Lukas Eder from jOOQ - the Java Object Oriented Query library (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 youtube.com/playlist?list=PL1ssMPpyqociJNwykAOB9_KEZVW7BW7m2 and the code on GitHub github.com/dmcg/gilded-rose-tdd Other database-specific episodes are collected in a playlist youtube.com/playlist?list=PL1ssMPpyqoci7HFHOmNbzkT_OAVqr9JBu If you like this, you’ll probably like my book Java to Kotlin, A Refactoring Guidebook (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 - duncan@oneeyedmen.comWhy it's here
1 person recommends thisWhat people say. Recommended as a practical guide to managing jOOQ transactions using Kotlin context receivers.
u/dmcgin r/Kotlin • Mentions
On “Using Flyway for Database Setup”
In our last episode (link to this video we decided to use jOOQ (https://www.jooq.org/), rather than JetBrains Exposed for our database access, but discovered that we were using Exposed to create our tables, so we couldn't remove it straight away.
The grown-up way of creating a database schema is migrations, and no-one ever got fired for choosing Flyway (https://flywaydb.org/), so that's what we'll investigate today. By the end we are able to create the same schema as Exposed was creating, and then, as a second migration, add some constraints to the items table to reflect the reality of our data. And the transition from Exposed to jOOQ is complete!
This is part 71 of an exploration of where a Test Dri…