Java 类org.jooq.conf.RenderNameStyle 实例源码

项目:AdvancedDataProfilingSeminar    文件:TestDatabase.java   
public void setUp() throws Exception {
  connection = DriverManager.getConnection("jdbc:hsqldb:mem:myDb");
  context = DSL.using(connection, SQLDialect.HSQLDB, new Settings().withRenderNameStyle(
      RenderNameStyle.AS_IS));

  final List<Field<String>> fields = getFields();

  context.createTable(relationName)
      .columns(fields)
      .execute();

  try (InputStream in = resourceClass.getResourceAsStream(csvPath)) {
    final Loader<Record> loader = context.loadInto(table(name(relationName)))
        .loadCSV(in)
        .fields(fields)
        .execute();

    assertThat(loader.errors()).isEmpty();
  }
}
项目:killbill-analytics-plugin    文件:SqlReportDataExtractor.java   
public SqlReportDataExtractor(final String tableName,
                              final ReportSpecification reportSpecification,
                              @Nullable final DateTime startDate,
                              @Nullable final DateTime endDate,
                              final SQLDialect sqlDialect,
                              final Long tenantRecordId) {
    this.tableName = tableName;
    this.reportSpecification = reportSpecification;
    this.startDate = startDate;
    this.endDate = endDate;
    this.tenantRecordId = tenantRecordId;

    final Settings settings = new Settings();
    settings.withStatementType(StatementType.STATIC_STATEMENT);
    settings.withRenderFormatted(true);
    if (SQLDialect.H2.equals(sqlDialect)) {
        settings.withRenderNameStyle(RenderNameStyle.AS_IS);
    }
    this.context = DSL.using(sqlDialect, settings);

    setup();
}
项目:java-persistence-frameworks-comparison    文件:DbTestsApplication.java   
@Bean
@Primary
public Settings jooqSettings() {
    Settings ret = new Settings();
    ret.withRenderSchema(false);
    ret.setRenderFormatted(true);

    ret.setRenderNameStyle(RenderNameStyle.AS_IS);
    return ret;
}
项目:keywhiz    文件:DSLContexts.java   
public static DSLContext databaseAgnostic(DataSource dataSource) throws SQLException {
SQLDialect dialect;
try (Connection conn = dataSource.getConnection()) {
  dialect = dialect(conn);

  // See https://github.com/jOOQ/jOOQ/issues/4730
  if (conn.getMetaData().getURL().startsWith("jdbc:pgsql:")) {
    dialect = POSTGRES;
  }
}
return DSL.using(dataSource, dialect,
        new Settings()
            .withRenderSchema(false)
            .withRenderNameStyle(RenderNameStyle.AS_IS));
}
项目:jooq-with-liquibase    文件:App.java   
public static void main(String[] args) {
    SQLDialect sqlDialect = args.length == 0 ? SQLDialect.HSQLDB : SQLDialect.POSTGRES; // SQLDialect.ORACLE

    Settings settings = new Settings()
        .withRenderFormatted(true)
        .withRenderSchema(TRUE)
        .withRenderNameStyle(RenderNameStyle.UPPER);
    if (sqlDialect == SQLDialect.POSTGRES) {
        String schema1Name = args[0];
        String schema2Name = args[1];
        settings.withRenderMapping(new RenderMapping()
            .withSchemata(
                new MappedSchema().withInput(SCHEMA1.getName()).withOutput(schema1Name),
                new MappedSchema().withInput(SCHEMA2.getName()).withOutput(schema2Name)));
    }

    Configuration config = new DefaultConfiguration()
        .set(sqlDialect)
        .set(settings);

    Configuration configuration = config;
    DSLContext dsl = DSL.using(configuration);

    System.out.println(
        dsl.select(A.ID, A.FLAG)
            .from(A)
            .join(B).on(B.NAME.eq(A.NAME))
            .toString());
}
项目:cattle    文件:Bootstrap.java   
private static Settings dbSetting(String name) {
    String prop = "db." + name + ".database";
    String database = ArchaiusUtil.getString(prop).get();

    Settings settings = new Settings();
    settings.setRenderSchema(false);
    settings.setExecuteLogging(false);

    String renderNameStyle = ArchaiusUtil.getString("db." + name + "." + database + ".render.name.style").get();
    if (renderNameStyle != null) {
        settings.setRenderNameStyle(RenderNameStyle.valueOf(renderNameStyle.trim().toUpperCase()));
    }

    return settings;
}
项目:cloud-cattle    文件:Configuration.java   
@PostConstruct
public void init() {
    String prop = "db." + name + ".database";
    String database = ArchaiusUtil.getString(prop).get();
    if ( database == null ) {
        throw new IllegalStateException("Failed to find config for [" + prop + "]");
    }

    try {
        SQLDialect dialect = SQLDialect.valueOf(database.trim().toUpperCase());
        set(dialect);
    } catch ( IllegalArgumentException e ) {
        throw new IllegalArgumentException("Invalid SQLDialect [" + database.toUpperCase() + "]", e);
    }

    if ( connectionProvider == null ) {
        set(new AutoCommitConnectionProvider(dataSource));
    } else {
        set(connectionProvider);
    }

    settings.setRenderSchema(false);

    String renderNameStyle = ArchaiusUtil.getString("db." + name + "." + database + ".render.name.style").get();
    if ( renderNameStyle != null ) {
        settings.setRenderNameStyle(RenderNameStyle.valueOf(renderNameStyle.trim().toUpperCase()));
    }

    set(settings);

    if ( listeners != null && listeners.size() > 0 ) {
        settings().setExecuteLogging(false);
        set(DefaultExecuteListenerProvider.providers(listeners.toArray(new ExecuteListener[listeners.size()])));
    }
}
项目:club-tracker    文件:ConfiguredConnector.java   
@Override
public Settings getSettings() {
    if(dialect == SQLDialect.POSTGRES) {
        return new Settings().withRenderNameStyle(RenderNameStyle.LOWER);
    }
    return updateSchema(dialect).map(s ->
            new Settings()
                    .withRenderNameStyle(RenderNameStyle.LOWER)
                    .withRenderMapping(new RenderMapping()
                    .withSchemata(
                        new MappedSchema().withInput(Club.CLUB.getName())
                                .withOutput(s))))
                .orElseGet(Settings::new);
}
项目:dstack    文件:Configuration.java   
@PostConstruct
public void init() {
    String prop = "db." + name + ".database";
    String database = ArchaiusUtil.getString(prop).get();
    if ( database == null ) {
        throw new IllegalStateException("Failed to find config for [" + prop + "]");
    }

    try {
        SQLDialect dialect = SQLDialect.valueOf(database.trim().toUpperCase());
        set(dialect);
    } catch ( IllegalArgumentException e ) {
        throw new IllegalArgumentException("Invalid SQLDialect [" + database.toUpperCase() + "]", e);
    }

    if ( connectionProvider == null ) {
        set(new AutoCommitConnectionProvider(dataSource));
    } else {
        set(connectionProvider);
    }

    Settings settings = new Settings();
    settings.setRenderSchema(false);

    String renderNameStyle = ArchaiusUtil.getString("db." + name + "." + database + ".render.name.style").get();
    if ( renderNameStyle != null ) {
        settings.setRenderNameStyle(RenderNameStyle.valueOf(renderNameStyle.trim().toUpperCase()));
    }

    set(settings);

    if ( listeners != null && listeners.size() > 0 ) {
        settings().setExecuteLogging(false);
        set(DefaultExecuteListenerProvider.providers(listeners.toArray(new ExecuteListener[listeners.size()])));
    }
}
项目:AdvancedDataProfilingSeminar    文件:DSLContextFactory.java   
private DSLContext hsqldb(final Connection connection) {
  final Settings settings = new Settings().withRenderNameStyle(RenderNameStyle.AS_IS);
  return DSL.using(connection, SQLDialect.HSQLDB, settings);
}
项目:ninja-jooq    文件:NinjaJooqLifecycle.java   
/**
 * This method reads the configuration properties from
 * your application.conf file and configures jOOQ accordingly.
 * 
 */
public final void startServer(){
    logger.info("Starting jOOQ Module.");

    // Setup basic parameters
    boolean renderSchema = ninjaProperties.getBooleanWithDefault(JOOQ_RENDER_SCHEMA, true);

    //renderMapping

    String renderNameStyleString = ninjaProperties.getWithDefault(JOOQ_RENDER_NAME_STYLE, "QUOTED");
    RenderNameStyle renderNameStyle = RenderNameStyle.fromValue(renderNameStyleString);
    String renderKeywordStyleString = ninjaProperties.getWithDefault(JOOQ_RENDER_KEYWORD_STYLE, "LOWER");
    RenderKeywordStyle renderKeywordStyle = RenderKeywordStyle.valueOf(renderKeywordStyleString);

    boolean renderFormatted = ninjaProperties.getBooleanWithDefault(JOOQ_RENDER_FORMATTED, false);

    String statementTypeString = ninjaProperties.getWithDefault(JOOQ_STATEMENT_TYPE, "PREPARED_STATEMENT");
    StatementType statementType = StatementType.valueOf(statementTypeString);

    boolean executeLogging = ninjaProperties.getBooleanWithDefault(JOOQ_EXECUTE_LOGGING, true);

    // Execute listeners

    boolean executeWithOptimisticLocking = ninjaProperties
            .getBooleanWithDefault(JOOQ_EXECUTE_WITH_OPTIMISTIC_LOCKING, true);

    boolean attachRecords = ninjaProperties.getBooleanWithDefault(JOOQ_ATTACH_RECORDS, true);

    String sqlDialectString = ninjaProperties.getWithDefault(JOOQ_SQL_DIALECT, "DEFAULT");
    SQLDialect sqlDialect = SQLDialect.valueOf(sqlDialectString);

    Settings settings = new Settings();
    settings.setRenderSchema(renderSchema);
    settings.setRenderNameStyle(renderNameStyle);
    settings.setRenderKeywordStyle(renderKeywordStyle);
    settings.setRenderFormatted(renderFormatted);
    settings.setStatementType(statementType);
    settings.setExecuteLogging(executeLogging);
    settings.setExecuteWithOptimisticLocking(executeWithOptimisticLocking);
    settings.setAttachRecords(attachRecords);

    String connectionUrl = ninjaProperties.getOrDie(NinjaConstant.DB_CONNECTION_URL);
    String connectionUsername = ninjaProperties.getOrDie(NinjaConstant.DB_CONNECTION_USERNAME);
    String connectionPassword = ninjaProperties.getWithDefault(NinjaConstant.DB_CONNECTION_PASSWORD, "");

    BasicDataSource connectionPool = new BasicDataSource();

    connectionPool.setUrl(connectionUrl);
    connectionPool.setUsername(connectionUsername);
    connectionPool.setPassword(connectionPassword);

    Configuration configuration = new DefaultConfiguration();
    configuration.set(sqlDialect);
    configuration.set(settings);
    configuration.set(connectionPool);

    dslContext = DSL.using(configuration);
}
项目:httpQL    文件:SelectBuilder.java   
public SelectBuilder<T> withRenderNameStyle(RenderNameStyle renderNameStyle) {
  this.renderNameStyle = renderNameStyle;
  return this;
}
项目:polygene-java    文件:AbstractSQLEntityStoreAssembler.java   
protected Settings getSettings()
{
    return new Settings().withRenderNameStyle( RenderNameStyle.QUOTED );
}
项目:ninja-jooq    文件:NinjaJooqLifecycle.java   
/**
 * This method reads the configuration properties from
 * your application.conf file and configures jOOQ accordingly.
 * 
 */
public final void startServer(){
    logger.info("Starting jOOQ Module.");

    // Setup basic parameters
    boolean renderSchema = ninjaProperties.getBooleanWithDefault(JOOQ_RENDER_SCHEMA, true);

    //renderMapping

    String renderNameStyleString = ninjaProperties.getWithDefault(JOOQ_RENDER_NAME_STYLE, "QUOTED");
    RenderNameStyle renderNameStyle = RenderNameStyle.fromValue(renderNameStyleString);
    String renderKeywordStyleString = ninjaProperties.getWithDefault(JOOQ_RENDER_KEYWORD_STYLE, "LOWER");
    RenderKeywordStyle renderKeywordStyle = RenderKeywordStyle.valueOf(renderKeywordStyleString);

    boolean renderFormatted = ninjaProperties.getBooleanWithDefault(JOOQ_RENDER_FORMATTED, false);

    String statementTypeString = ninjaProperties.getWithDefault(JOOQ_STATEMENT_TYPE, "PREPARED_STATEMENT");
    StatementType statementType = StatementType.valueOf(statementTypeString);

    boolean executeLogging = ninjaProperties.getBooleanWithDefault(JOOQ_EXECUTE_LOGGING, true);

    // Execute listeners

    boolean executeWithOptimisticLocking = ninjaProperties
            .getBooleanWithDefault(JOOQ_EXECUTE_WITH_OPTIMISTIC_LOCKING, true);

    boolean attachRecords = ninjaProperties.getBooleanWithDefault(JOOQ_ATTACH_RECORDS, true);

    String sqlDialectString = ninjaProperties.getWithDefault(JOOQ_SQL_DIALECT, "DEFAULT");
    SQLDialect sqlDialect = SQLDialect.valueOf(sqlDialectString);

    Settings settings = new Settings();
    settings.setRenderSchema(renderSchema);
    settings.setRenderNameStyle(renderNameStyle);
    settings.setRenderKeywordStyle(renderKeywordStyle);
    settings.setRenderFormatted(renderFormatted);
    settings.setStatementType(statementType);
    settings.setExecuteLogging(executeLogging);
    settings.setExecuteWithOptimisticLocking(executeWithOptimisticLocking);
    settings.setAttachRecords(attachRecords);

    String connectionUrl = ninjaProperties.getOrDie(NinjaConstant.DB_CONNECTION_URL);
    String connectionUsername = ninjaProperties.getOrDie(NinjaConstant.DB_CONNECTION_USERNAME);
    String connectionPassword = ninjaProperties.getWithDefault(NinjaConstant.DB_CONNECTION_PASSWORD, "");

    BasicDataSource connectionPool = new BasicDataSource();

    connectionPool.setUrl(connectionUrl);
    connectionPool.setUsername(connectionUsername);
    connectionPool.setPassword(connectionPassword);

    Configuration configuration = new DefaultConfiguration();
    configuration.set(sqlDialect);
    configuration.set(settings);
    configuration.set(connectionPool);

    dslContext = DSL.using(configuration);
}