use of org.jooq.impl.DefaultConfiguration in project SimpleFlatMapper by arnaudroger.
the class JooqMapperTest method testMapperDbExtendedType.
@Test
public void testMapperDbExtendedType() throws Exception {
Connection conn = DbHelper.objectDb();
DSLContext dsl = DSL.using(new DefaultConfiguration().set(conn).set(SQLDialect.HSQLDB).set(SfmRecordMapperProviderFactory.newInstance().newProvider()));
List<DbExtendedType> list = dsl.select().from("db_extended_type").fetchInto(DbExtendedType.class);
assertEquals(1, list.size());
DbExtendedType o = list.get(0);
DbExtendedType.assertDbExtended(o);
}
use of org.jooq.impl.DefaultConfiguration in project steve by RWTH-i5-IDSG.
the class BeanConfiguration method dslContext.
/**
* Can we re-use DSLContext as a Spring bean (singleton)? Yes, the Spring tutorial of
* Jooq also does it that way, but only if we do not change anything about the
* config after the init (which we don't do anyways) and if the ConnectionProvider
* does not store any shared state (we use DataSourceConnectionProvider of Jooq, so no problem).
*
* Some sources and discussion:
* - http://www.jooq.org/doc/3.6/manual/getting-started/tutorials/jooq-with-spring/
* - http://jooq-user.narkive.com/2fvuLodn/dslcontext-and-threads
* - https://groups.google.com/forum/#!topic/jooq-user/VK7KQcjj3Co
* - http://stackoverflow.com/questions/32848865/jooq-dslcontext-correct-autowiring-with-spring
*/
@Bean
public DSLContext dslContext() {
initDataSource();
Settings settings = new Settings().withAttachRecords(false).withExecuteLogging(CONFIG.getDb().isSqlLogging());
// Configuration for JOOQ
org.jooq.Configuration conf = new DefaultConfiguration().set(SQLDialect.MYSQL).set(new DataSourceConnectionProvider(dataSource)).set(settings);
return DSL.using(conf);
}
use of org.jooq.impl.DefaultConfiguration in project mapping-benchmark by arnaudroger.
the class JooqSfmRecordMapperBenchmark method init.
@Setup
public void init() throws Exception {
ConnectionParam cp = new ConnectionParam();
cp.db = db;
cp.init();
dsl = DSL.using(new DefaultConfiguration().set(cp.dataSource).set(JooqMapperBenchmark.getSqlDialect(db)).set(new SfmRecordMapperProvider()));
select4 = dsl.selectFrom(TestSmallBenchmarkObject.TEST_SMALL_BENCHMARK_OBJECT);
select16 = dsl.selectFrom(TestBenchmarkObject_16.TEST_BENCHMARK_OBJECT_16);
}
use of org.jooq.impl.DefaultConfiguration in project mapping-benchmark by arnaudroger.
the class JooqSfmRecordMapperBenchmark method main.
public static void main(String[] args) throws SQLException, NamingException {
ConnectionParam cp = new ConnectionParam();
cp.db = DbTarget.H2;
cp.init();
DSLContext dsl = DSL.using(new DefaultConfiguration().set(cp.dataSource).set(JooqMapperBenchmark.getSqlDialect(cp.db)).set(new SfmRecordMapperProvider()));
SelectOffsetStep<TestSmallBenchmarkObjectRecord> query = dsl.selectFrom(TestSmallBenchmarkObject.TEST_SMALL_BENCHMARK_OBJECT).limit(1);
for (MappedObject4 o : query.fetchInto(MappedObject4.class)) {
System.out.println("o = " + o);
}
for (MappedObject4 o : query.fetchInto(MappedObject4.class)) {
System.out.println("o = " + o);
}
}
use of org.jooq.impl.DefaultConfiguration in project vertx-zero by silentbalanceyh.
the class JooqInfix method initInternal.
private static void initInternal(final Vertx vertx, final String name) {
vertxRef = vertx;
Fn.pool(CONFIGS, name, () -> Infix.init(Plugins.Infix.JOOQ, (config) -> {
// Initialized client
final Configuration configuration = new DefaultConfiguration();
configuration.set(SQLDialect.MYSQL_8_0);
final ConnectionProvider provider = new DefaultConnectionProvider(HikariCpPool.getConnection(config.getJsonObject("provider")));
// Initialized default configuration
configuration.set(provider);
return configuration;
}, JooqInfix.class));
}
Aggregations