use of org.jdbi.v3.core.result.ResultIterable in project jdbi by jdbi.
the class TestDocumentation method testMappingExampleChainedIterator3.
@Test
public void testMappingExampleChainedIterator3() {
try (Handle h = h2Extension.openHandle()) {
h.execute("insert into something (id, name) values (1, 'Brian')");
h.execute("insert into something (id, name) values (2, 'Keith')");
ResultIterable<String> names = h.createQuery("select name from something order by id").mapTo(String.class);
assertThat(names.iterator()).toIterable().containsExactly("Brian", "Keith");
}
}
use of org.jdbi.v3.core.result.ResultIterable in project jdbi by jdbi.
the class TestQueries method testMapper.
@Test
public void testMapper() {
Handle h = h2Extension.openHandle();
h.execute("insert into something (id, name) values (1, 'eric')");
h.execute("insert into something (id, name) values (2, 'brian')");
ResultIterable<String> query = h.createQuery("select name from something order by id").map((r, ctx) -> r.getString(1));
List<String> r = query.list();
assertThat(r).startsWith("eric");
}
Aggregations