本文整理了Java中com.avaje.ebean.Query.findEach
方法的一些代码示例,展示了Query.findEach
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.findEach
方法的具体详情如下:
包路径:com.avaje.ebean.Query
类名称: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 QueryEachConsumer (SAM) 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(),但不是使用迭代器,而是使用QueryAchConsumer(SAM)接口,该接口更适合用于Java8闭包。
ebeanServer.find(Customer.class));
}
代码示例来源:origin: org.actframework/act-ebean-java7
@Override
public void findEach(QueryEachConsumer<MODEL_TYPE> consumer) {
qReadOnly.findEach(consumer);
}
代码示例来源:origin: org.avaje.ebean/ebean
@Override
public void findEach(Consumer<T> consumer) {
query.findEach(consumer);
}
内容来源于网络,如有侵权,请联系作者删除!