Skip to content
This repository was archived by the owner on Mar 3, 2026. It is now read-only.

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

README.md

jOOQ

jOOQ generates Java code from your database and lets you build type safe SQL queries through its fluent API.

This module depends on jdbc module, make sure you read the doc of the jdbc module.

exports

  • DSLContext

dependency

<dependency>
 <groupId>org.jooby</groupId>
 <artifactId>jooby-jooq</artifactId>
 <version>1.1.2</version>
</dependency>

usage

{
  use(new jOOQ());

  get("/jooq", req -> {

    try (DSLContext ctx = require(DSLContext.class)) {
      return ctx.transactionResult(conf -> {
        DSLContext trx = DSL.using(conf);
        return trx.selectFrom(TABLE)
            .where(ID.eq(1))
            .fetchOne(NAME);
      });
    }
  });

}

multiple db connections

{
  use(new jOOQ("db.main"));

  use(new jOOQ("db.audit"));

  get("/main", req -> {

    try (DSLContext ctx = require("db.main", DSLContext.class)) {
      ...
    }
  });

  get("/audit", req -> {

    try (DSLContext ctx = require("db.audit", DSLContext.class)) {
      ...
    }
  });

}

advanced configuration

This module setup a Configuration object with a DataSource from jdbc module and the DefaultTransactionProvider. More advanced configuration is provided via #doWith(BiConsumer):

{
  use(new jOOQ().doWith(conf -> {

    conf.set(...);
  });

}

code generation

Unfortunately, this module doesn't provide any built-in facility for code generation. If you need help to setup the code generator please checkout the jOOQ documentation for more information.