use of org.jdbi.v3.core.mapper.SomethingMapper in project jdbi by jdbi.
the class TestNewApiOnDbiAndHandle method setUp.
@Before
public void setUp() throws Exception {
JdbcDataSource ds = new JdbcDataSource();
ds.setURL("jdbc:h2:mem:" + UUID.randomUUID());
db = Jdbi.create(ds);
db.installPlugin(new SqlObjectPlugin());
db.registerRowMapper(new SomethingMapper());
handle = db.open();
handle.execute("create table something (id int primary key, name varchar(100))");
}
use of org.jdbi.v3.core.mapper.SomethingMapper in project jdbi by jdbi.
the class TestReentrancy method setUp.
@Before
public void setUp() throws Exception {
JdbcDataSource ds = new JdbcDataSource();
// in MVCC mode h2 doesn't shut down immediately on all connections closed, so need random db name
ds.setURL(String.format("jdbc:h2:mem:%s;MVCC=TRUE", UUID.randomUUID()));
db = Jdbi.create(ds);
db.installPlugin(new SqlObjectPlugin());
db.registerRowMapper(new SomethingMapper());
handle = db.open();
handle.execute("create table something (id int primary key, name varchar(100))");
}
use of org.jdbi.v3.core.mapper.SomethingMapper in project jdbi by jdbi.
the class TestVavrTupleRowMapperFactoryWithDB method testMapTuple3WithoutSpecifiedColumn_shouldFail.
@Test
public void testMapTuple3WithoutSpecifiedColumn_shouldFail() throws SQLException {
Handle handle = dbRule.getSharedHandle();
handle.registerRowMapper(new SomethingMapper());
assertThatThrownBy(() -> handle.createQuery("select * from something where id = 1").mapTo(new GenericType<Tuple3<Integer, Something, Integer>>() {
}).findOnly()).isInstanceOf(NoSuchMapperException.class).hasMessageContaining("TupleMappers config class");
}
use of org.jdbi.v3.core.mapper.SomethingMapper in project jdbi by jdbi.
the class TestVavrTupleRowMapperFactoryWithDB method testMapTuple3WithOnlyOneSpecifiedColumn_shouldFail.
@Test
public void testMapTuple3WithOnlyOneSpecifiedColumn_shouldFail() throws SQLException {
Handle handle = dbRule.getSharedHandle();
handle.registerRowMapper(new SomethingMapper());
handle.configure(TupleMappers.class, c -> c.setColumn(1, "integerValue"));
assertThatThrownBy(() -> handle.createQuery("select * from something where id = 1").mapTo(new GenericType<Tuple3<Integer, Something, Integer>>() {
}).findOnly()).isInstanceOf(NoSuchMapperException.class).isInstanceOf(NoSuchMapperException.class).hasMessageContaining("TupleMappers config class");
}
use of org.jdbi.v3.core.mapper.SomethingMapper in project jdbi by jdbi.
the class BindBeanListTest method init.
@BeforeClass
public static void init() {
final Jdbi db = dbRule.getJdbi();
db.installPlugin(new SqlObjectPlugin());
db.registerRowMapper(new SomethingMapper());
handle = db.open();
handle.execute("insert into something(id, name) values(1, '1')");
handle.execute("insert into something(id, name) values(2, '2')");
// "control group" element that should *not* be returned by the queries
handle.execute("insert into something(id, name) values(3, '3')");
expectedSomethings = Arrays.asList(new Something(1, "1"), new Something(2, "2"));
}
Aggregations