#811 - ENH: Restore findIterate() as alternative to findEach / findEachWhile

This commit is contained in:
Robin Bygrave committed 2016-08-05 13:01:42 +12:00
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")