With Apache Cayenne, what is the benefit of using the “batch iterator” compared to the classic “java.util.Iterator” ?
What is a usage scenario?
// same, but iterate in batches
try (ResultBatchIterator<Artist> it = ObjectSelect.query(Artist.class).batchIterator(context, 100)) {
it.forEach(batch -> {
ObjectContext editContext = runtime.newContext();
// do something with each object in the batch
editContext.commitChanges();
});
}