Search in sources :

Example 1 with DefaultConfiguration

use of org.jooq.impl.DefaultConfiguration in project SimpleFlatMapper by arnaudroger.

the class JooqMapperTest method testMapperDbObject.

@Test
public void testMapperDbObject() throws Exception {
    Connection conn = DbHelper.objectDb();
    DSLContext dsl = DSL.using(new DefaultConfiguration().set(conn).set(SQLDialect.HSQLDB).set(new SfmRecordMapperProvider()));
    List<DbObject> list = dsl.select().from("TEST_DB_OBJECT").fetchInto(DbObject.class);
    assertEquals(2, list.size());
    DbHelper.assertDbObjectMapping(list.get(0));
}
Also used : DbObject(org.simpleflatmapper.test.beans.DbObject) SfmRecordMapperProvider(org.simpleflatmapper.jooq.SfmRecordMapperProvider) Connection(java.sql.Connection) DefaultConfiguration(org.jooq.impl.DefaultConfiguration) Test(org.junit.Test)

Example 2 with DefaultConfiguration

use of org.jooq.impl.DefaultConfiguration in project SimpleFlatMapper by arnaudroger.

the class JooqMapperTest method testIgnoreFields.

@Test
public void testIgnoreFields() throws Exception {
    Connection conn = DbHelper.objectDb();
    DSLContext dsl = DSL.using(new DefaultConfiguration().set(conn).set(SQLDialect.HSQLDB).set(SfmRecordMapperProviderFactory.newInstance().addAlias("id", "noId").ignorePropertyNotFound().newProvider()));
    List<DbObject> list = dsl.select().from("TEST_DB_OBJECT").fetchInto(DbObject.class);
    assertEquals(2, list.size());
    assertEquals(0, list.get(0).getId());
    list.get(0).setId(1);
    DbHelper.assertDbObjectMapping(list.get(0));
}
Also used : DbObject(org.simpleflatmapper.test.beans.DbObject) Connection(java.sql.Connection) DefaultConfiguration(org.jooq.impl.DefaultConfiguration) Test(org.junit.Test)

Example 3 with DefaultConfiguration

use of org.jooq.impl.DefaultConfiguration in project mapping-benchmark by arnaudroger.

the class JooqMapperBenchmark 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(getSqlDialect(db)));
    select4 = dsl.selectFrom(TestSmallBenchmarkObject.TEST_SMALL_BENCHMARK_OBJECT);
    select16 = dsl.selectFrom(TestBenchmarkObject_16.TEST_BENCHMARK_OBJECT_16);
}
Also used : ConnectionParam(org.simpleflatmapper.db.ConnectionParam) DefaultConfiguration(org.jooq.impl.DefaultConfiguration)

Example 4 with DefaultConfiguration

use of org.jooq.impl.DefaultConfiguration in project mapping-benchmark by arnaudroger.

the class JooqSfmBenchmark 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);
}
Also used : SfmRecordMapperProvider(org.simpleflatmapper.jooq.SfmRecordMapperProvider) ConnectionParam(org.simpleflatmapper.db.ConnectionParam) DefaultConfiguration(org.jooq.impl.DefaultConfiguration)

Example 5 with DefaultConfiguration

use of org.jooq.impl.DefaultConfiguration in project mapping-benchmark by arnaudroger.

the class JooqRecordBenchmark 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)));
    select4 = dsl.selectFrom(TestSmallBenchmarkObject.TEST_SMALL_BENCHMARK_OBJECT);
    select16 = dsl.selectFrom(TestBenchmarkObject_16.TEST_BENCHMARK_OBJECT_16);
}
Also used : ConnectionParam(org.simpleflatmapper.db.ConnectionParam) DefaultConfiguration(org.jooq.impl.DefaultConfiguration)

Aggregations

DefaultConfiguration (org.jooq.impl.DefaultConfiguration)27 Settings (org.jooq.conf.Settings)7 Connection (java.sql.Connection)6 Configuration (org.jooq.Configuration)6 DSLContext (org.jooq.DSLContext)6 ConnectionParam (org.simpleflatmapper.db.ConnectionParam)6 Test (org.junit.Test)5 DefaultExecuteListenerProvider (org.jooq.impl.DefaultExecuteListenerProvider)4 SfmRecordMapperProvider (org.simpleflatmapper.jooq.SfmRecordMapperProvider)4 Bean (org.springframework.context.annotation.Bean)4 Properties (java.util.Properties)3 SQLDialect (org.jooq.SQLDialect)3 DataSourceConnectionProvider (org.jooq.impl.DataSourceConnectionProvider)3 DefaultConnectionProvider (org.jooq.impl.DefaultConnectionProvider)3 Provides (dagger.Provides)2 List (java.util.List)2 Singleton (javax.inject.Singleton)2 BasicDataSource (org.apache.commons.dbcp.BasicDataSource)2 ConnectionProvider (org.jooq.ConnectionProvider)2 DbObject (org.simpleflatmapper.test.beans.DbObject)2