org.jooq.meta.jaxb.Jdbc Java Examples

The following examples show how to use org.jooq.meta.jaxb.Jdbc. 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: PostgresConfigurationProvider.java    From vertx-jooq with MIT License 6 votes vote down vote up
@Override
public Configuration createGeneratorConfig(String generatorName, String packageName, Class<? extends VertxGeneratorStrategy> generatorStrategy){
    Jdbc jdbcConfig = new Jdbc();
    jdbcConfig.setDriver("org.postgresql.Driver");
    jdbcConfig.setUrl("jdbc:postgresql://127.0.0.1:5432/postgres");
    jdbcConfig.setUser(Credentials.POSTGRES.getUser());
    jdbcConfig.setPassword(Credentials.POSTGRES.getPassword());
    Configuration generatorConfig = createGeneratorConfig(generatorName, packageName, generatorStrategy, jdbcConfig, PostgresDatabase.class.getName());
    ForcedType customJsonMapping = new ForcedType();
    customJsonMapping.setUserType(SomeJsonPojo.class.getName());
    customJsonMapping.setConverter(SomeJsonPojoConverter.class.getName());
    customJsonMapping.setExpression("someCustomJsonObject");
    customJsonMapping.setTypes(".*");
    List<ForcedType> forcedTypes = new ArrayList<>(generatorConfig.getGenerator().getDatabase().getForcedTypes());
    forcedTypes.add(customJsonMapping);
    generatorConfig.getGenerator().getDatabase().setForcedTypes(forcedTypes);
    return generatorConfig;
}
 
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: 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 #5
Source File: HsqldbConfigurationProvider.java    From vertx-jooq with MIT License 5 votes vote down vote up
@Override
public Configuration createGeneratorConfig(String generatorName, String packageName, Class<? extends VertxGeneratorStrategy> generatorStrategy){
    Jdbc jdbcConfig = new Jdbc();
    jdbcConfig.setDriver("org.hsqldb.jdbcDriver");
    jdbcConfig.setUrl("jdbc:hsqldb:mem:test");
    jdbcConfig.setUser(Credentials.HSQLDB.getUser());
    jdbcConfig.setPassword(Credentials.HSQLDB.getPassword());
    return createGeneratorConfig(generatorName, packageName, generatorStrategy, jdbcConfig, HSQLDBDatabase.class.getName());
}
 
Example #6
Source File: MySQLConfigurationProvider.java    From vertx-jooq with MIT License 5 votes vote down vote up
@Override
public Configuration createGeneratorConfig(String generatorName, String packageName, Class<? extends VertxGeneratorStrategy> generatorStrategy){
    Jdbc jdbcConfig = new Jdbc();
    jdbcConfig.setDriver("com.mysql.jdbc.Driver");
    jdbcConfig.setUrl("jdbc:mysql://127.0.0.1:3306/");
    jdbcConfig.setUser(Credentials.MYSQL.getUser());
    jdbcConfig.setPassword(Credentials.MYSQL.getPassword());
    jdbcConfig.setSchema("vertx");
    return createGeneratorConfig(generatorName,packageName,generatorStrategy,jdbcConfig, MySQLDatabase.class.getName());
}