Back to articles list
- 3 minutes read

The Easiest ERD + ORM Integration Ever: Vertabelo and jOOQ

What is jOOQ?

jOOQ, which stands for "jOOQ Object Oriented Querying," is an ORM (object-relational mapping) for Java. With jOOQ you don't write statements with "SQL-like language"; like Hibernate's HQL. Instead, you write well designed and intuitive DSL code which, for someone speaking SQL, is obvious and self-explanatory. Read more »

Some time ago I announced that the integration of Vertabelo and jOOQ was coming soon. While we're waiting for an official (stable) jOOQ release to support this integration, I'd like to present you with some of the details about how to use this new feature.

How It Used to Be

In my first experiments with jOOQ I used reverse-engineering to generate ORM classes. I had to create a database and then configure it in a codegen XML file like this:




This is a standard procedure in jOOQ setup, described in step 3 of the "Getting started" tutorial.

How It Can Be Done Now

As I described in the previous post, you can now choose from two more sources of information to obtain the database structure: a Vertabelo XML file stored locally or data that jOOQ downloads directly from Vertabelo.

Local Vertabelo XML File

In this first scenario, you model your DB structure in Vertabelo, export it as a Vertabelo XML file and use it with jOOQ. The only change you have to make for this import to work is to modify the codegen configuration file. It looks like this:



The section is now obsolete – we don't need to connect to the existing database. Since you don't use a DBMS-specific implementation of the generator, you must explicitly provide the proper dialect. You can find the list of dialects supported by jOOQ here. In my case it's "POSTGRES."

Download Directly From the Cloud

If you run the code generator only after making some changes to the DB structure (as opposed to using the "regenerate with every build" strategy) and you don't want to store the XML locally (or in the repository), you can let jOOQ take care of downloading the XML from Vertabelo. You only have to worry about making changes in Vertabelo and running the code generator – it's as simple as that! The only setup effort you have to do is, once again, change a standard jOOQ codegen XML file:



As you can see, you must provide the Vertabelo API token, model identifier and, as in the previous case, the dialect.

That's it. After a standard one-time setup, you can enjoy the power of both Vertabelo and jOOQ working together.

go to top