![]() ![]() While we can generate UUID in the database using gen_random_uuid() method, I will not use it here to make the example a bit more universal. ![]() Nice and simple! All right, now let’s generate jOOQ classes for that table. The final model of ShmonitoringEvent we ended up with last time looks like this (see the full code on GitHub): data class ShmonitoringEventRequest(įor the sake of simplicity, we will ignore status field for now, and focus on other fields.Īccording to the models above, here’s what our table definition might look like: CREATE TABLE events Our SQL database engine of choice at Wolt is PostgreSQL, so that’s what we’re going to use here. sql file with a list of DDL statements as a migration script. We will use Flyway here, as it’s pretty straightforward to use. The 2 most popular tools to achieve that are Flyway and Liquibase. Usually, it’s also a good idea to have some way to version your database changes. Since jOOQ is a database first library, first thing we need to do is declare the schema we’d like to have. We will start with declaring the DB schema, configuring jOOQ code generation and then will implement a repository to save and fetch monitoring events.Īlso, to keep things simple for the time being, we will avoid using any dependency injection frameworks. In this article we will continue developing the monitoring service we started building before in « How to build a good API with Kotlin». Let’s see how we can build a convenient and type safe data access layer with jOOQ and Kotlin. It is an ORM library that sticks close to SQL, allowing you to write fast and efficient queries while providing a nice, type safe API for that. ![]() Many services at Wolt rely on jOOQ for data access. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |