本文整理了Java中org.skife.jdbi.v2.Query.cleanupHandle
方法的一些代码示例,展示了Query.cleanupHandle
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.cleanupHandle
方法的具体详情如下:
包路径:org.skife.jdbi.v2.Query
类名称:Query
方法名:cleanupHandle
暂无
代码示例来源:origin: org.jdbi/jdbi
@Test
public void testNonPathologicalJustNext() throws Exception {
h.createStatement("insert into something (id, name) values (1, 'eric')").execute();
// Yes, you *should* use first(). But sometimes, an iterator is passed 17 levels deep and then
// used in this way (Hello Jackson!).
final Map<String, Object> result = h.createQuery("select * from something order by id")
.cleanupHandle()
.iterator()
.next();
assertEquals(1, result.get("id"));
assertEquals("eric", result.get("name"));
}
代码示例来源:origin: org.kill-bill.commons/killbill-jdbi
@Test
public void testNonPathologicalJustNext() throws Exception {
h.createStatement("insert into something (id, name) values (1, 'eric')").execute();
// Yes, you *should* use first(). But sometimes, an iterator is passed 17 levels deep and then
// used in this way (Hello Jackson!).
final Map<String, Object> result = h.createQuery("select * from something order by id")
.cleanupHandle()
.iterator()
.next();
assertEquals(1, result.get("id"));
assertEquals("eric", result.get("name"));
}
代码示例来源:origin: org.jdbi/jdbi
@Test
public void testClosing() throws Exception {
h.createStatement("insert into something (id, name) values (1, 'eric')").execute();
h.createStatement("insert into something (id, name) values (2, 'brian')").execute();
List<Map<String, Object>> results = h.createQuery("select * from something order by id")
.cleanupHandle()
.list();
assertEquals(2, results.size());
Map<String, Object> first_row = results.get(0);
assertEquals("eric", first_row.get("name"));
assertTrue(h.isClosed());
}
代码示例来源:origin: org.jdbi/jdbi
@Test
public void testEmptyWorksToo() throws Exception {
ResultIterator<Map<String, Object>> it = h.createQuery("select * from something order by id")
.cleanupHandle()
.iterator();
assertFalse(it.hasNext());
}
代码示例来源:origin: org.kill-bill.commons/killbill-jdbi
@Test
public void testClosing() throws Exception {
h.createStatement("insert into something (id, name) values (1, 'eric')").execute();
h.createStatement("insert into something (id, name) values (2, 'brian')").execute();
List<Map<String, Object>> results = h.createQuery("select * from something order by id")
.cleanupHandle()
.list();
assertEquals(2, results.size());
Map<String, Object> first_row = results.get(0);
assertEquals("eric", first_row.get("name"));
assertTrue(h.isClosed());
}
代码示例来源:origin: org.jdbi/jdbi
@Test
public void testEmptyExplosion() throws Exception {
ResultIterator<Map<String, Object>> it = h.createQuery("select * from something order by id")
.cleanupHandle()
.iterator();
try {
it.next();
fail("Expected IllegalStateException did not show up!");
}
catch (IllegalStateException iae) {
// TestCase does not deal with the annotations...
}
}
代码示例来源:origin: org.kill-bill.commons/killbill-jdbi
@Test
public void testEmptyWorksToo() throws Exception {
ResultIterator<Map<String, Object>> it = h.createQuery("select * from something order by id")
.cleanupHandle()
.iterator();
assertFalse(it.hasNext());
}
代码示例来源:origin: org.kill-bill.commons/killbill-jdbi
@Test
public void testEmptyExplosion() throws Exception {
ResultIterator<Map<String, Object>> it = h.createQuery("select * from something order by id")
.cleanupHandle()
.iterator();
try {
it.next();
fail("Expected IllegalStateException did not show up!");
}
catch (IllegalStateException iae) {
// TestCase does not deal with the annotations...
}
}
代码示例来源:origin: org.kill-bill.commons/killbill-jdbi
@Test
public void testBasicCleanupIterator()
throws Exception
{
final Handle handle = dbi.open();
final Query<Integer> q = handle.createQuery("SELECT COUNT(1) FROM something")
.cleanupHandle()
.map(IntegerMapper.FIRST);
final ResultIterator<Integer> it = q.iterator();
assertEquals(COUNT, Iterators.getOnlyElement(it).intValue());
assertFalse(it.hasNext());
assertTrue(handle.getConnection().isClosed());
}
代码示例来源:origin: org.jdbi/jdbi
@Test
public void testBasicCleanupIterator()
throws Exception
{
final Handle handle = dbi.open();
final Query<Integer> q = handle.createQuery("SELECT COUNT(1) FROM something")
.cleanupHandle()
.mapTo(Integer.class);
final ResultIterator<Integer> it = q.iterator();
assertEquals(COUNT, Iterators.getOnlyElement(it).intValue());
assertFalse(it.hasNext());
assertTrue(handle.getConnection().isClosed());
}
代码示例来源:origin: org.jdbi/jdbi
@Test
public void testJustNext() throws Exception {
h.createStatement("insert into something (id, name) values (1, 'eric')").execute();
h.createStatement("insert into something (id, name) values (2, 'brian')").execute();
h.createStatement("insert into something (id, name) values (3, 'john')").execute();
ResultIterator<Map<String, Object>> it = h.createQuery("select * from something order by id")
.cleanupHandle()
.iterator();
it.next();
it.next();
it.next();
}
代码示例来源:origin: org.kill-bill.commons/killbill-jdbi
@Test
public void testJustNext() throws Exception {
h.createStatement("insert into something (id, name) values (1, 'eric')").execute();
h.createStatement("insert into something (id, name) values (2, 'brian')").execute();
h.createStatement("insert into something (id, name) values (3, 'john')").execute();
ResultIterator<Map<String, Object>> it = h.createQuery("select * from something order by id")
.cleanupHandle()
.iterator();
it.next();
it.next();
it.next();
}
代码示例来源:origin: org.jdbi/jdbi
@Test
public void testIterateAllTheWay() throws Exception {
h.createStatement("insert into something (id, name) values (1, 'eric')").execute();
h.createStatement("insert into something (id, name) values (2, 'brian')").execute();
ResultIterator<Map<String, Object>> it = h.createQuery("select * from something order by id")
.cleanupHandle()
.iterator();
int cnt = 0;
while(it.hasNext()) {
cnt++;
it.next();
}
assertEquals(2, cnt);
assertTrue(h.isClosed());
}
代码示例来源:origin: org.kill-bill.commons/killbill-jdbi
@Test
public void testIterateAllTheWay() throws Exception {
h.createStatement("insert into something (id, name) values (1, 'eric')").execute();
h.createStatement("insert into something (id, name) values (2, 'brian')").execute();
ResultIterator<Map<String, Object>> it = h.createQuery("select * from something order by id")
.cleanupHandle()
.iterator();
int cnt = 0;
while(it.hasNext()) {
cnt++;
it.next();
}
assertEquals(2, cnt);
assertTrue(h.isClosed());
}
代码示例来源:origin: org.jdbi/jdbi
@Test
public void testNext() throws Exception {
h.createStatement("insert into something (id, name) values (1, 'eric')").execute();
h.createStatement("insert into something (id, name) values (2, 'brian')").execute();
h.createStatement("insert into something (id, name) values (3, 'john')").execute();
ResultIterator<Map<String, Object>> it = h.createQuery("select * from something order by id")
.cleanupHandle()
.iterator();
assertTrue(it.hasNext());
it.next();
it.next();
it.next();
assertFalse(it.hasNext());
}
代码示例来源:origin: org.kill-bill.commons/killbill-jdbi
@Test
public void testNext() throws Exception {
h.createStatement("insert into something (id, name) values (1, 'eric')").execute();
h.createStatement("insert into something (id, name) values (2, 'brian')").execute();
h.createStatement("insert into something (id, name) values (3, 'john')").execute();
ResultIterator<Map<String, Object>> it = h.createQuery("select * from something order by id")
.cleanupHandle()
.iterator();
assertTrue(it.hasNext());
it.next();
it.next();
it.next();
assertFalse(it.hasNext());
}
代码示例来源:origin: org.jdbi/jdbi
@Test
public void testTwoOne() throws Exception {
h.createStatement("insert into something (id, name) values (1, 'eric')").execute();
h.createStatement("insert into something (id, name) values (2, 'brian')").execute();
h.createStatement("insert into something (id, name) values (3, 'john')").execute();
ResultIterator<Map<String, Object>> it = h.createQuery("select * from something order by id")
.cleanupHandle()
.iterator();
assertTrue(it.hasNext());
it.next();
it.next();
assertTrue(it.hasNext());
it.next();
assertFalse(it.hasNext());
}
代码示例来源:origin: org.kill-bill.commons/killbill-jdbi
@Test
public void testTwoOne() throws Exception {
h.createStatement("insert into something (id, name) values (1, 'eric')").execute();
h.createStatement("insert into something (id, name) values (2, 'brian')").execute();
h.createStatement("insert into something (id, name) values (3, 'john')").execute();
ResultIterator<Map<String, Object>> it = h.createQuery("select * from something order by id")
.cleanupHandle()
.iterator();
assertTrue(it.hasNext());
it.next();
it.next();
assertTrue(it.hasNext());
it.next();
assertFalse(it.hasNext());
}
代码示例来源:origin: org.kill-bill.commons/killbill-jdbi
@Test
public void testTwoTwo() throws Exception {
h.createStatement("insert into something (id, name) values (1, 'eric')").execute();
h.createStatement("insert into something (id, name) values (2, 'brian')").execute();
h.createStatement("insert into something (id, name) values (3, 'john')").execute();
ResultIterator<Map<String, Object>> it = h.createQuery("select * from something order by id")
.cleanupHandle()
.iterator();
it.next();
it.next();
assertTrue(it.hasNext());
assertTrue(it.hasNext());
it.next();
assertFalse(it.hasNext());
assertFalse(it.hasNext());
}
代码示例来源:origin: org.jdbi/jdbi
@Test
public void testTwoTwo() throws Exception {
h.createStatement("insert into something (id, name) values (1, 'eric')").execute();
h.createStatement("insert into something (id, name) values (2, 'brian')").execute();
h.createStatement("insert into something (id, name) values (3, 'john')").execute();
ResultIterator<Map<String, Object>> it = h.createQuery("select * from something order by id")
.cleanupHandle()
.iterator();
it.next();
it.next();
assertTrue(it.hasNext());
assertTrue(it.hasNext());
it.next();
assertFalse(it.hasNext());
assertFalse(it.hasNext());
}
内容来源于网络,如有侵权,请联系作者删除!