Yes, you can programmatically configure jOOQ's code generator. When you look at GenerationTool
's source code, you'll see that you can call its overloaded main()
method either from the console (as documented in the manual), or by passing it an org.jooq.util.jaxb.Configuration
object. An example:
import org.jooq.util.jaxb.*;
// [...]
Configuration configuration = new Configuration()
.withJdbc(new Jdbc()
.withDriver("com.mysql.jdbc.Driver")
.withUrl("jdbc:mysql://localhost:3306/library")
.withUser("root")
.withPassword("root"))
.withGenerator(new Generator()
.withName("org.jooq.util.DefaultGenerator")
.withDatabase(new Database()
.withName("org.jooq.util.mysql.MySQLDatabase")
.withIncludes(".*")
.withExcludes("")
.withInputSchema("library"))
.withTarget(new Target()
.withPackageName("org.jooq.util.maven.example")
.withDirectory("target/generated-sources/jooq")));
GenerationTool.main(configuration);
The above configuration POJOs are generated by XJC, so you can use exactly the same structure as with the XML configuration.