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.
DSLContext
<dependency>
<groupId>org.jooby</groupId>
<artifactId>jooby-jooq</artifactId>
<version>1.1.2</version>
</dependency>{
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);
});
}
});
}{
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)) {
...
}
});
}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(...);
});
}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.