io.ebean.Query.findEach()方法的使用及代码示例

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

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

Query.findEach介绍

[英]Execute the query processing the beans one at a time.

This method is appropriate to process very large query results as the beans are consumed one at a time and do not need to be held in memory (unlike #findList #findSet etc)

Note that findEach (and findEachWhile and findIterate) uses a "per graph" persistence context scope and adjusts jdbc fetch buffer size for large queries. As such it is better to use findList for small queries.

Note that internally Ebean can inform the JDBC driver that it is expecting larger resultSet and specifically for MySQL this hint is required to stop it's JDBC driver from buffering the entire resultSet. As such, for smaller resultSets findList() is generally preferable.

Compared with #findEachWhile this will always process all the beans where as #findEachWhile provides a way to stop processing the query result early before all the beans have been read.

This method is functionally equivalent to findIterate() but instead of using an iterator uses the Consumer interface which is better suited to use with Java8 closures.

ebeanServer.find(Customer.class)); 
}

[中]执行查询,一次处理一个bean。
这种方法适合处理非常大的查询结果,因为bean一次消耗一个,不需要保存在内存中(与#findList#findSet等不同)
请注意,findEach(以及findEachWhile和findIterate)使用“每图”持久性上下文范围,并为大型查询调整jdbc获取缓冲区大小。因此,对于小型查询,最好使用findList。
注意,Ebean可以在内部通知JDBC驱动程序,它希望得到更大的resultSet,特别是对于MySQL,需要这个提示来阻止它的JDBC驱动程序缓冲整个resultSet。因此,对于较小的结果集,findList()通常更可取。
与#findEachWhile相比,它将始终处理所有bean,而as#findEachWhile提供了一种在读取所有bean之前提前停止处理查询结果的方法。
这个方法在功能上等同于findIterate(),但不是使用迭代器,而是使用更适合与Java8闭包一起使用的使用者接口。

ebeanServer.find(Customer.class)); 
}

代码示例

代码示例来源:origin: ebean-orm/ebean

@Override
public void findEach(Consumer<T> consumer) {
 query.findEach(consumer);
}

代码示例来源:origin: io.ebean/ebean

@Override
public void findEach(Consumer<T> consumer) {
 query.findEach(consumer);
}

代码示例来源:origin: org.actframework/act-ebean

@Override
public void findEach(Consumer<MODEL_TYPE> consumer) {
  qReadOnly.findEach(consumer);
}

代码示例来源:origin: org.actframework/act-ebean2

@Override
public void findEach(Consumer<MODEL_TYPE> consumer) {
  q.findEach(consumer);
}

代码示例来源:origin: io.ebean/ebean-querybean

query.findEach(consumer);

代码示例来源:origin: icode/ameba

/** {@inheritDoc} */
@Override
public List<ScriptInfo> allScript() {
  final List<ScriptInfo> scriptInfoList = Lists.newArrayList();
  server.find(ScriptInfo.class).findEach(scriptInfoList::add);
  return scriptInfoList;
}

代码示例来源:origin: icode/ameba

/**
 * {@inheritDoc}
 */
public void findEach(Consumer<T> consumer) {
  query().findEach(consumer);
}

代码示例来源:origin: icode/ameba

.findEach(bean -> resources.add(new MigrationResource(bean)));

相关文章

Query类方法