作者:白杨树问天 | 来源:互联网 | 2023-09-23 19:37
本文整理了Java中org.jdbi.v3.core.result.ResultIterable.withStream
方法的一些代码示例,展示了ResultIterable.withStream
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ResultIterable.withStream
方法的具体详情如下:
包路径:org.jdbi.v3.core.result.ResultIterable
类名称:ResultIterable
方法名:withStream
ResultIterable.withStream介绍
[英]Passes the stream of results to the callback. Database resources owned by the query are released before this method returns.
[中]将结果流传递给回调。在该方法返回之前,将释放查询所拥有的数据库资源。
代码示例
代码示例来源:origin: jdbi/jdbi
/**
* Passes the stream of results to the consumer. Database resources owned by the query are
* released before this method returns.
*
* @param consumer a consumer which receives the stream of results.
* @param the exception type thrown by the callback, if any
*
* @throws X any exception thrown by the callback
*/
default void useStream(StreamConsumer consumer) throws X {
withStream(stream -> {
consumer.useStream(stream);
return null;
});
}
代码示例来源:origin: jdbi/jdbi
@Test
public void testListWithMaxRows() {
h.prepareBatch("insert into something (id, name) values (?, ?)")
.add(1, "Brian")
.add(2, "Keith")
.add(3, "Eric")
.execute();
assertThat(h.createQuery("select id, name from something")
.mapToBean(Something.class)
.withStream(stream -> stream.limit(1).count())
.longValue()).isEqualTo(1);
assertThat(h.createQuery("select id, name from something")
.mapToBean(Something.class)
.withStream(stream -> stream.limit(2).count())
.longValue()).isEqualTo(2);
}
代码示例来源:origin: org.jdbi/jdbi3
/**
* Passes the stream of results to the consumer. Database resources owned by the query are
* released before this method returns.
*
* @param consumer a consumer which receives the stream of results.
* @param the exception type thrown by the callback, if any
*
* @throws X any exception thrown by the callback
*/
default void useStream(StreamConsumer consumer) throws X {
withStream(stream -> {
consumer.useStream(stream);
return null;
});
}