org.jooq.meta.jaxb.Configuration Java Examples

The following examples show how to use org.jooq.meta.jaxb.Configuration. 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: HsqldbConfigurationProvider.java    From vertx-jooq with MIT License 5 votes vote down vote up
@Override
public org.jooq.Configuration createDAOConfiguration(){
    org.jooq.Configuration configuration = new DefaultConfiguration();
    configuration.set(SQLDialect.HSQLDB);
    try {
        configuration.set(DriverManager.getConnection("jdbc:hsqldb:mem:test", "test", ""));
    } catch (SQLException e) {
        throw new AssertionError("Failed setting up DB.",e);
    }
    return configuration;
}
 
Example #7
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());
}
 
Example #8
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());
    }
}
 
Example #9
Source File: CustomVertxGeneratorTest.java    From vertx-jooq with MIT License 5 votes vote down vote up
public CustomVertxGeneratorTest() {
    super(CustomVertxGenerator.class, VertxGeneratorStrategy.class,"classic.jdbc.custom", new HsqldbConfigurationProvider(){
        @Override
        public Configuration createGeneratorConfig(String generatorName, String packageName, Class<? extends VertxGeneratorStrategy> generatorStrategy) {
            org.jooq.meta.jaxb.Configuration conf =  super.createGeneratorConfig(generatorName, packageName, generatorStrategy);
            //see if generator without interfaces produces compilable classes
            conf.getGenerator().getGenerate().setInterfaces(false);
            return conf;
        }
    });
}
 
Example #10
Source File: MySQLConfigurationProvider.java    From vertx-jooq with MIT License 4 votes vote down vote up
@Override
public org.jooq.Configuration createDAOConfiguration() {
    return new DefaultConfiguration().set(SQLDialect.MYSQL);
}
 
Example #11
Source File: PostgresConfigurationProvider.java    From vertx-jooq with MIT License 4 votes vote down vote up
@Override
public org.jooq.Configuration createDAOConfiguration(){
    return new DefaultConfiguration().set(SQLDialect.POSTGRES);
}