Search in sources :

Example 46 with Configuration

use of org.jooq.Configuration in project SimpleFlatMapper by arnaudroger.

the class SelectQueryMapperTest method testSelectQuery.

@Test
public void testSelectQuery() throws SQLException {
    Connection conn = DbHelper.objectDb();
    Configuration cfg = new DefaultConfiguration().set(conn).set(SQLDialect.HSQLDB);
    DSLContext dsl = DSL.using(cfg);
    SelectQueryMapper<Label> mapper = SelectQueryMapperFactory.newInstance().newMapper(Label.class);
    UUID uuid1 = UUID.randomUUID();
    Label label = new Label(1, uuid1, "l1", false);
    dsl.insertInto(Labels.LABELS).columns(Labels.LABELS.ID, Labels.LABELS.NAME, Labels.LABELS.OBSOLETE, Labels.LABELS.UUID).values(1, "l1", false, uuid1).execute();
    List<Label> labels = mapper.asList(dsl.select(Labels.LABELS.ID, Labels.LABELS.NAME, Labels.LABELS.OBSOLETE, Labels.LABELS.UUID).from(Labels.LABELS));
    assertEquals(1, labels.size());
    assertEquals(label, labels.get(0));
}
Also used : DefaultConfiguration(org.jooq.impl.DefaultConfiguration) Configuration(org.jooq.Configuration) Connection(java.sql.Connection) DSLContext(org.jooq.DSLContext) DefaultConfiguration(org.jooq.impl.DefaultConfiguration) UUID(java.util.UUID) Test(org.junit.Test)

Aggregations

Configuration (org.jooq.Configuration)46 DSLContext (org.jooq.DSLContext)13 List (java.util.List)9 ArrayList (java.util.ArrayList)8 ExecuteContext (org.jooq.ExecuteContext)8 Query (org.jooq.Query)8 Record (org.jooq.Record)6 DefaultConfiguration (org.jooq.impl.DefaultConfiguration)6 Arrays (java.util.Arrays)5 SQLDialect (org.jooq.SQLDialect)5 BigInteger (java.math.BigInteger)4 OffsetDateTime (java.time.OffsetDateTime)4 Arrays.asList (java.util.Arrays.asList)4 Map (java.util.Map)4 Optional (java.util.Optional)4 DataAccessException (org.jooq.exception.DataAccessException)4 JooqLogger (org.jooq.tools.JooqLogger)4 SQLException (java.sql.SQLException)3 HashMap (java.util.HashMap)3 LinkedHashMap (java.util.LinkedHashMap)3