org.skife.jdbi.v2.Query.cleanupHandle()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(10.0k)|赞(0)|评价(0)|浏览(124)

本文整理了Java中org.skife.jdbi.v2.Query.cleanupHandle方法的一些代码示例,展示了Query.cleanupHandle的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.cleanupHandle方法的具体详情如下:
包路径:org.skife.jdbi.v2.Query
类名称:Query
方法名:cleanupHandle

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());
}

相关文章