I ran into a bug in which I expected a result set of about 3600 rows and get 1. The row I get back is the last row of the result set I see in Oracle SQL Developer. I've traced the issue to handleRowValues() in NestedResultSetHandler. Based on tracing thru that code in the debugger the row value gets set by the line:
rowValue = getRowValue(rs, discriminatedResultMap, rowKey, rowKey, null, resultColumnCache, partialObject);
but then nothing actually happens with the value. It would appear that the if statement right after should be within the bracket directly above it (existing source below):
while (shouldProcessMoreRows(rs, resultContext, rowBounds)) {
final ResultMap discriminatedResultMap = resolveDiscriminatedResultMap(rs, resultMap, null);
final CacheKey rowKey = createRowKey(discriminatedResultMap, rs, null, resultColumnCache);
Object partialObject = objectCache.get(rowKey);
if (partialObject == null && rowValue != null) { // issue #542 delay calling ResultHandler until object ends
if (mappedStatement.isResultOrdered()) objectCache.clear(); // issue #577 clear memory if ordered
callResultHandler(resultHandler, resultContext, rowValue);
}
rowValue = getRowValue(rs, discriminatedResultMap, rowKey, rowKey, null, resultColumnCache, partialObject);
}
if (rowValue != null) callResultHandler(resultHandler, resultContext, rowValue);
In the 3.1.1 release the rowValue is bieng put into another collection:
while (shouldProcessMoreRows(rs, resultContext, rowBounds)) {
final ResultMap discriminatedResultMap = resolveDiscriminatedResultMap(rs, resultMap, null);
final CacheKey rowKey = createRowKey(discriminatedResultMap, rs, null, resultColumnCache);
final boolean knownValue = objectCache.containsKey(rowKey);
Object rowValue = getRowValue(rs, discriminatedResultMap, rowKey, resultColumnCache);
if (!knownValue) {
resultContext.nextResultObject(rowValue);
resultHandler.handleResult(resultContext);
}
}
EDIT: maybe not quite that simple as I didn't look at the source enough before posting. Based on more debugging the callResultHandler inside the if statement (thats inside the while loop) is never getting called. That would explain why i am only seeing the last row of the resultset in the returned collection. its being put in there by the second if.
bug