Search in sources :

Example 6 with SomethingMapper

use of org.jdbi.v3.core.mapper.SomethingMapper in project jdbi by jdbi.

the class TestModifiers method setUp.

@Before
public void setUp() throws Exception {
    handle = dbRule.getSharedHandle();
    handle.registerRowMapper(new SomethingMapper());
}
Also used : SomethingMapper(org.jdbi.v3.core.mapper.SomethingMapper) Before(org.junit.Before)

Example 7 with SomethingMapper

use of org.jdbi.v3.core.mapper.SomethingMapper in project jdbi by jdbi.

the class TestReducing method setUp.

@Before
public void setUp() {
    Handle h = dbRule.getSharedHandle();
    h.execute("CREATE TABLE something_location (id int, location varchar)");
    h.execute("INSERT INTO something (id, name) VALUES (1, 'tree')");
    h.execute("INSERT INTO something (id, name) VALUES (2, 'apple')");
    h.execute("INSERT INTO something_location (id, location) VALUES (1, 'outside')");
    h.execute("INSERT INTO something_location (id, location) VALUES (2, 'tree')");
    h.execute("INSERT INTO something_location (id, location) VALUES (2, 'pie')");
    h.registerRowMapper(new SomethingMapper());
}
Also used : SomethingMapper(org.jdbi.v3.core.mapper.SomethingMapper) Handle(org.jdbi.v3.core.Handle) Before(org.junit.Before)

Example 8 with SomethingMapper

use of org.jdbi.v3.core.mapper.SomethingMapper in project jdbi by jdbi.

the class TestRegisteredMappers method testRegisterInferredOnJdbi.

@Test
public void testRegisterInferredOnJdbi() throws Exception {
    db.registerRowMapper(new SomethingMapper());
    Something sam = db.withHandle(handle1 -> {
        handle1.execute("insert into something (id, name) values (18, 'Sam')");
        return handle1.createQuery("select id, name from something where id = :id").bind("id", 18).mapTo(Something.class).findOnly();
    });
    assertThat(sam.getName()).isEqualTo("Sam");
}
Also used : Something(org.jdbi.v3.core.Something) Test(org.junit.Test)

Example 9 with SomethingMapper

use of org.jdbi.v3.core.mapper.SomethingMapper in project jdbi by jdbi.

the class TestRegisteredMappersWork method testRegistered.

@Test
public void testRegistered() throws Exception {
    dbRule.getSharedHandle().registerRowMapper(new SomethingMapper());
    Spiffy s = dbRule.getSharedHandle().attach(Spiffy.class);
    s.insert(1, "Tatu");
    Something t = s.byId(1);
    assertThat(t).isEqualTo(new Something(1, "Tatu"));
}
Also used : SomethingMapper(org.jdbi.v3.core.mapper.SomethingMapper) Something(org.jdbi.v3.core.Something) Test(org.junit.Test)

Example 10 with SomethingMapper

use of org.jdbi.v3.core.mapper.SomethingMapper in project jdbi by jdbi.

the class TestCreateSqlObjectAnnotation method setUp.

@Before
public void setUp() throws Exception {
    dbRule.getJdbi().registerRowMapper(new SomethingMapper());
    handle = dbRule.getSharedHandle();
    handle.registerRowMapper(new SomethingMapper());
}
Also used : SomethingMapper(org.jdbi.v3.core.mapper.SomethingMapper) Before(org.junit.Before)

Aggregations

SomethingMapper (org.jdbi.v3.core.mapper.SomethingMapper)16 Something (org.jdbi.v3.core.Something)8 Test (org.junit.Test)8 Handle (org.jdbi.v3.core.Handle)7 Before (org.junit.Before)6 GenericType (org.jdbi.v3.core.generic.GenericType)4 JdbcDataSource (org.h2.jdbcx.JdbcDataSource)3 Jdbi (org.jdbi.v3.core.Jdbi)3 NoSuchMapperException (org.jdbi.v3.core.mapper.NoSuchMapperException)3 BeforeClass (org.junit.BeforeClass)3 Tuple2 (io.vavr.Tuple2)1 Tuple3 (io.vavr.Tuple3)1 Connection (java.sql.Connection)1