org.jooq.codegen.GenerationTool Java Examples

The following examples show how to use org.jooq.codegen.GenerationTool. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JooqCodeGenerator.java    From hadoop-ozone with Apache License 2.0 6 votes vote down vote up
/**
 * Generate entity and DAO classes.
 */
private void generateSourceCode(String outputDir) throws Exception {
  Configuration configuration =
      new Configuration()
          .withJdbc(new Jdbc()
              .withDriver(DERBY_DRIVER_CLASS)
              .withUrl(JDBC_URL))
          .withGenerator(new Generator()
              .withDatabase(new Database()
                  .withName("org.jooq.meta.derby.DerbyDatabase")
                  .withOutputSchemaToDefault(true)
                  .withIncludeTables(true)
                  .withIncludePrimaryKeys(true)
                  .withInputSchema(RECON_SCHEMA_NAME))
              .withGenerate(new Generate()
                  .withDaos(true)
                  .withEmptyCatalogs(true))
              .withStrategy(new Strategy().withName(
                  "org.hadoop.ozone.recon.codegen.TableNamingStrategy"))
              .withTarget(new Target()
                  .withPackageName("org.hadoop.ozone.recon.schema")
                  .withClean(true)
                  .withDirectory(outputDir)))
              .withLogging(Logging.WARN);
  GenerationTool.generate(configuration);
}
 
Example #2
Source File: CMSMigrations.java    From StubbornJava with MIT License 5 votes vote down vote up
public static void codegen() throws Exception {
    List<ForcedType> forcedTypes = JooqConfig.defaultForcedTypes();

    HikariDataSource ds = CMSConnectionPools.processing();

    Configuration configuration = new Configuration()
        .withJdbc(new Jdbc()
            .withDriver(Driver.class.getName())
            .withUrl(ds.getJdbcUrl())
            .withUser(ds.getUsername())
            .withPassword(ds.getPassword()))
        .withGenerator(new Generator()
            .withDatabase(new Database()
                .withName(MySQLDatabase.class.getName())
                .withIncludes(".*")
                .withExcludes("")
                .withIncludeExcludeColumns(true)
                .withForcedTypes(forcedTypes)
                .withInputSchema("sj_cms"))
            .withGenerate(new Generate()
                .withJavaTimeTypes(true))
            .withStrategy(new Strategy()
                .withName(CustomGeneratorStrategy.class.getName()))
            .withTarget(new Target()
                .withPackageName("com.stubbornjava.cms.server.generated")
                .withDirectory("src/generated/java")));

    GenerationTool.generate(configuration);
}
 
Example #3
Source File: CMSMigrations.java    From StubbornJava with MIT License 5 votes vote down vote up
public static void codegen() throws Exception {
    List<ForcedType> forcedTypes = JooqConfig.defaultForcedTypes();

    HikariDataSource ds = CMSConnectionPools.processing();

    Configuration configuration = new Configuration()
        .withJdbc(new Jdbc()
            .withDriver(Driver.class.getName())
            .withUrl(ds.getJdbcUrl())
            .withUser(ds.getUsername())
            .withPassword(ds.getPassword()))
        .withGenerator(new Generator()
            .withDatabase(new Database()
                .withName(MySQLDatabase.class.getName())
                .withIncludes(".*")
                .withExcludes("")
                .withIncludeExcludeColumns(true)
                .withForcedTypes(forcedTypes)
                .withInputSchema("sj_cms"))
            .withGenerate(new Generate()
                .withJavaTimeTypes(true))
            .withStrategy(new Strategy()
                .withName(CustomGeneratorStrategy.class.getName()))
            .withTarget(new Target()
                .withPackageName("com.stubbornjava.cms.server.generated")
                .withDirectory("src/generated/java")));

    GenerationTool.generate(configuration);
}
 
Example #4
Source File: AbstractVertxGeneratorTest.java    From vertx-jooq with MIT License 5 votes vote down vote up
@Test
public void generateCodeShouldSucceed() throws Exception {
    configurationProvider.setupDatabase();
    Configuration configuration = configurationProvider.createGeneratorConfig(
            generator.getName(), packageLocation, strategy);
    configuration.setOnError(OnError.FAIL);
    configuration.setLogging(Logging.WARN);
    try {
        GenerationTool.generate(configuration);
        Assert.assertTrue(true);
    } catch (Throwable e) {
        e.printStackTrace();
        Assert.fail(e.getMessage());
    }
}