Deprecated, use vertx-jooq instead:
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.

deprecation warning

I started vertx-jooq-async a couple months after working on vertx-jooq to allow the same features but using the async driver. First, I tried to incorproate it into vertx-jooq but it couldn't be done without a major refactoring (which I didn't have the time for), so I created this repository. In the following weeks it bothered me more and more, that if I had to fix a bug, it had to be done two times. Also both projects shared a similar API: again a lot of duplicate code.

In the last weeks I finally found some time to refactor vertx-jooq so it incorporates now both, the JDBC and the async driver. Because of that, vertx-jooq-async will no longer be maintained.


The real async version of vertx-jooq: a jOOQ-CodeGenerator to create vertx-ified DAOs and POJOs! This time with a real asynchronous driver. That's right - no JDBC.

differences to vertx-jooq

This project uses jOOQ for code-generation and to render queries. The query execution is done by the AsyncJooqSQLClient which wraps a io.vertx.ext.asyncsql.AsyncSQLClient. The executeAsync-method has been removed from VertxDao, instead you need to call the client() method on the DAO to execute custom SQL-statements (see example below) on the AsyncJooqSQLClient.


//Setup your jOOQ configuration
Configuration configuration = new DefaultConfiguration();
configuration.set(SQLDialect.MYSQL); //or SQLDialect.POSTGRES
//no other DB-Configuration necessary because jOOQ is only used to render our statements - not for excecution

//setup Vertx
Vertx vertx = Vertx.vertx();
//setup the client
JsonObject config = new JsonObject().put("host", "").put("username", "vertx").putNull("password").put("database","vertx");
AsyncJooqSQLClient client = AsyncJooqSQLClient.create(vertx,MySQLClient.createNonShared(vertx, config))

//instantiate a DAO (which is generated for you)
SomethingDao dao = new SomethingDao(configuration);

//fetch something with ID 123...
CompletableFuture<Void> sendFuture =

//maybe consume it in another verticle
vertx.eventBus().<JsonObject>consumer("sendSomething", jsonEvent->{
    JsonObject message = jsonEvent.body();
    //Convert it back into a POJO...
    Something something = new Something(message);
    //... change some values
    //... and update it into the DB
    CompletableFuture<Void> updatedFuture = dao.updateAsync(something);

    //or do you prefer writing your own typesafe SQL?
    CompletableFuture<Something> selectFuture = dao.client().fetchOne(DSL.using(dao.configuration()).selectFrom(Tables.SOMETHING).orderBy(Tables.SOMETHING.SOMEID.desc()).limit(1),dao.jsonMapper());
    //check for completion
            System.out.println("It's something! "+something.toJson());
            System.err.println("Something failed badly: "+ex.getMessage());

callback? future? rx?

Again, this library comes in different flavors:

  • the classic callback-handler style.
  • a API that returns a vertx-ified implementation of java.util.concurrent.CompletableFuture for all async DAO operations and thus makes chaining your async operations easier. It has some limitations which you need to be aware about (see known issues).
  • a RX Java based API

Depending on your needs, you have to include one of the following dependencies into your pom:



maven code generator configuration example for mysql

The following code-snippet can be copy-pasted into your pom.xml to generate code from your MySQL database schema.

Watch out for placeholders beginning with 'YOUR_xyz' though! E.g. you have to define credentials for DB access and specify the target directory where jOOQ should put the generated code into, otherwise it won't run!

After you replaced all placeholders with valid values, you should be able to run mvn generate-sources which creates all POJOs and DAOs into the target directory you specified.

If you are new to jOOQ, I recommend to read the awesome jOOQ documentation, especially the chapter about code generation.

...your project configuration here...

    ...your other dependencies...
          <!-- Specify the maven code generator plugin -->

          <!-- The plugin should hook into the generate goal -->


          <!-- Specify the plugin configuration.
               The configuration format is the same as for the standalone code generator -->
              <!-- JDBC connection parameters -->

              <!-- Generator parameters -->
                          <!-- Convert tinyint to boolean -->
                          <!-- Convert varchar column with name 'someJsonObject' to a io.vertx.core.json.JsonObject-->
                          <!-- Convert varchar column with name 'someJsonArray' to a io.vertx.core.json.JsonArray-->
                      <!-- This is where jOOQ will put your files -->



programmatic configuration of the code generator

See the TestTool of how to setup the generator programmatically.

known issues

  • insertReturningPrimary-method only works for MySQL and numeric keys.
  • Only available for MySQL and Postgres.
  • Nobody can prevent you from calling one of the blocking fetch- or execute-methods on the VertxDAO or a jOOQ-query. If you do it, jOOQ will try to execute the query by itself using JDBC (if properly configured). So try to avoid it at any cost.
  • Currently no Guice support