本文整理了Java中org.jdbi.v3.core.statement.Query.setFetchSize
方法的一些代码示例,展示了Query.setFetchSize
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.setFetchSize
方法的具体详情如下:
包路径:org.jdbi.v3.core.statement.Query
类名称:Query
方法名:setFetchSize
[英]Specify the fetch size for the query. This should cause the results to be fetched from the underlying RDBMS in groups of rows equal to the number passed. This is useful for doing chunked streaming of results when exhausting memory could be a problem.
[中]指定查询的提取大小。这将导致从底层RDBMS中以与传递的行数相等的行组获取结果。当耗尽内存可能是一个问题时,这对于执行分块的结果流非常有用。
代码示例来源:origin: jdbi/jdbi
@Override
public SqlStatementParameterCustomizer createForParameter(Annotation annotation,
Class<?> sqlObjectType,
Method method,
Parameter param,
int index,
Type type) {
return (stmt, fetchSize) -> ((Query) stmt).setFetchSize((Integer) fetchSize);
}
}
代码示例来源:origin: jdbi/jdbi
@Override
public SqlStatementCustomizer createForType(Annotation annotation, Class<?> sqlObjectType) {
int fetchSize = ((FetchSize) annotation).value();
return stmt -> ((Query) stmt).setFetchSize(fetchSize);
}
代码示例来源:origin: jdbi/jdbi
@Test
public void testFetchSize() {
h.createScript(findSqlOnClasspath("default-data")).execute();
ResultIterable<Something> ri = h.createQuery("select id, name from something order by id")
.setFetchSize(1)
.mapToBean(Something.class);
ResultIterator<Something> r = ri.iterator();
assertThat(r.hasNext()).isTrue();
r.next();
assertThat(r.hasNext()).isTrue();
r.next();
assertThat(r.hasNext()).isFalse();
}
内容来源于网络,如有侵权,请联系作者删除!