@SuppressWarnings("unchecked")
protected T fetchNextObject() throws HBqlException {
final HResultSetImpl<T, R> rs = this.getResultSet();
final SelectStatement selectStatement = rs.getSelectStmt();
final ResultAccessor resultAccessor = selectStatement.getMappingContext().getResultAccessor();
while (this.getCurrentResultIterator() != null || moreResultsPending()) {
if (this.getCurrentResultIterator() == null)
this.setCurrentResultIterator(this.getNextResultIterator());
while (this.getCurrentResultIterator() != null
&& this.getCurrentResultIterator().hasNext()) {
final Result result = this.getCurrentResultIterator().next();
try {
if (rs.getClientExpressionTree() != null
&& !rs.getClientExpressionTree().evaluate(rs.getHConnectionImpl(), result))
continue;
}
catch (ResultMissingColumnException e) {
continue;
}
catch (NullColumnValueException e) {
continue;
}
this.incrementReturnedRecordCount();
if (selectStatement.isAnAggregateQuery()) {
this.getResultSet().getAggregateRecord().applyValues(result);
}
else {
final T val = (T)resultAccessor.newObject(rs.getHConnectionImpl(),
selectStatement.getMappingContext(),
selectStatement.getSelectElementList(),
rs.getMaxVersions(),
result);
return rs.getQuery().callOnEachRow(val);
}