mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-28 23:28:55 +00:00
#811 - ENH: Restore findIterate() as alternative to findEach / findEachWhile
This commit is contained in:
1 parent
6c182ecaa5
commit
43afaf1344
19 files changed
+211
-70
No files matched your search
@@ -470,6 +470,11 @@ public class TDSpiEbeanServer implements SpiEbeanServer {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> QueryIterator<T> findIterate(Query<T> query, Transaction transaction) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> void findEach(Query<T> query, QueryEachConsumer<T> consumer, Transaction transaction) {
|
||||
|
||||
|
||||
@@ -27,6 +27,32 @@ public class TestQueryFindIterate extends BaseTestCase {
|
||||
|
||||
EbeanServer server = Ebean.getServer(null);
|
||||
|
||||
Query<Customer> query = server.find(Customer.class)
|
||||
.setMaxRows(2);
|
||||
|
||||
final AtomicInteger count = new AtomicInteger();
|
||||
|
||||
QueryIterator<Customer> it = query.findIterate();
|
||||
try {
|
||||
while (it.hasNext()) {
|
||||
Customer customer = it.next();
|
||||
customer.getName();
|
||||
count.incrementAndGet();
|
||||
}
|
||||
} finally {
|
||||
it.close();
|
||||
}
|
||||
|
||||
assertEquals(2, count.get());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void findEach() {
|
||||
|
||||
ResetBasicData.reset();
|
||||
|
||||
EbeanServer server = Ebean.getServer(null);
|
||||
|
||||
Query<Customer> query = server.find(Customer.class)
|
||||
.setAutoTune(false)
|
||||
//.fetch("contacts", new FetchConfig().query(2)).where().gt("id", 0).orderBy("id")
|
||||
|
||||
Reference in new issue
Block a user