#821 - CQueryIteratorSimple not working with consecutive calls to hasNext() - ie. without matching calls to next()

This commit is contained in:
Robin Bygrave committed 2016-10-03 23:36:03 +13:00
1 parent 014a9aef6f
commit 4f98ca5d91
2 files changed
+45 -1

No files matched your search

@@ -83,6 +83,11 @@ public class CQuery<T> implements DbReadContext, CancelableQuery {
*/
private EntityBean currentBean;
/**
* Caches hasNext for consecutive hasNext() calls.
*/
private boolean hasNextCache;
private final BeanPropertyAssocMany<?> lazyLoadManyProperty;
private Object lazyLoadParentId;
@@ -504,6 +509,7 @@ public class CQuery<T> implements DbReadContext, CancelableQuery {
if (auditFindIterate) {
auditIterateNextBean();
}
hasNextCache = false;
return nextBean;
}
@@ -513,7 +519,11 @@ public class CQuery<T> implements DbReadContext, CancelableQuery {
if (noMoreRows || cancelled || loadedBeanCount >= maxRowsLimit) {
return false;
}
return readNextBean();
if (hasNextCache) {
return true;
}
hasNextCache = readNextBean();
return hasNextCache;
}
}