Search in sources :

Example 21 with Settings

use of org.jooq.conf.Settings in project jOOQ by jOOQ.

the class Example_4_3_Settings method run.

@Test
public void run() {
    Select<?> select = DSL.select().from(AUTHOR).where(AUTHOR.ID.eq(3));
    Tools.title("A couple of settings at work - Formatting");
    out.println(using(H2, new Settings().withRenderFormatted(false)).render(select));
    out.println(using(H2, new Settings().withRenderFormatted(true)).render(select));
    Tools.title("A couple of settings at work - Schema");
    out.println(using(H2, new Settings().withRenderSchema(false)).render(select));
    out.println(using(H2, new Settings().withRenderSchema(true)).render(select));
    Tools.title("A couple of settings at work - Name case");
    out.println(using(H2, new Settings().withRenderNameCase(RenderNameCase.AS_IS)).render(select));
    out.println(using(H2, new Settings().withRenderNameCase(RenderNameCase.UPPER)).render(select));
    out.println(using(H2, new Settings().withRenderNameCase(RenderNameCase.LOWER)).render(select));
    Tools.title("A couple of settings at work - Name quoting");
    out.println(using(H2, new Settings().withRenderQuotedNames(RenderQuotedNames.ALWAYS)).render(select));
    out.println(using(H2, new Settings().withRenderQuotedNames(RenderQuotedNames.EXPLICIT_DEFAULT_QUOTED)).render(select));
    out.println(using(H2, new Settings().withRenderQuotedNames(RenderQuotedNames.EXPLICIT_DEFAULT_UNQUOTED)).render(select));
    out.println(using(H2, new Settings().withRenderQuotedNames(RenderQuotedNames.NEVER)).render(select));
    Tools.title("A couple of settings at work - Keyword case");
    out.println(using(H2, new Settings().withRenderKeywordCase(RenderKeywordCase.AS_IS)).render(select));
    out.println(using(H2, new Settings().withRenderKeywordCase(RenderKeywordCase.LOWER)).render(select));
    out.println(using(H2, new Settings().withRenderKeywordCase(RenderKeywordCase.UPPER)).render(select));
    out.println(using(H2, new Settings().withRenderKeywordCase(RenderKeywordCase.PASCAL)).render(select));
    Tools.title("A couple of settings at work - Mapping");
    out.println(using(H2, new Settings().withRenderMapping(new RenderMapping().withSchemata(new MappedSchema().withInput("PUBLIC").withOutput("test").withTables(new MappedTable().withInput("AUTHOR").withOutput("test-author"))))).render(select));
}
Also used : MappedSchema(org.jooq.conf.MappedSchema) MappedTable(org.jooq.conf.MappedTable) RenderMapping(org.jooq.conf.RenderMapping) Settings(org.jooq.conf.Settings) Test(org.junit.Test)

Example 22 with Settings

use of org.jooq.conf.Settings in project curiostack by curioswitch.

the class DatabaseModule method dbContext.

@Provides
@Singleton
static DSLContext dbContext(DataSource dataSource, @ForDatabase ListeningExecutorService dbExecutor) {
    Configuration configuration = new DefaultConfiguration().set(dbExecutor).set(SQLDialect.MYSQL).set(new Settings().withRenderSchema(false)).set(new DataSourceConnectionProvider(dataSource)).set(DatabaseUtil.sfmRecordMapperProvider());
    DSLContext ctx = DSL.using(configuration);
    // Eagerly trigger JOOQ classinit for better startup performance.
    ctx.select().from("curio_server_framework_init").getSQL();
    return ctx;
}
Also used : DefaultConfiguration(org.jooq.impl.DefaultConfiguration) Configuration(org.jooq.Configuration) DataSourceConnectionProvider(org.jooq.impl.DataSourceConnectionProvider) DSLContext(org.jooq.DSLContext) DefaultConfiguration(org.jooq.impl.DefaultConfiguration) Settings(org.jooq.conf.Settings) Singleton(javax.inject.Singleton) Provides(dagger.Provides)

Aggregations

Settings (org.jooq.conf.Settings)22 DSLContext (org.jooq.DSLContext)10 DefaultConfiguration (org.jooq.impl.DefaultConfiguration)7 Connection (java.sql.Connection)5 List (java.util.List)5 Configuration (org.jooq.Configuration)5 SQLDialect (org.jooq.SQLDialect)4 ArrayList (java.util.ArrayList)3 Test (org.junit.Test)3 PreparedStatement (java.sql.PreparedStatement)2 SQLException (java.sql.SQLException)2 Statement (java.sql.Statement)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 MappedSchema (org.jooq.conf.MappedSchema)2 MappedTable (org.jooq.conf.MappedTable)2 RenderMapping (org.jooq.conf.RenderMapping)2 DataAccessException (org.jooq.exception.DataAccessException)2 DSL (org.jooq.impl.DSL)2 DataSourceConnectionProvider (org.jooq.impl.DataSourceConnectionProvider)2