code: private List iterateAndReturn(ResultSet rSet, EntityMetadata metadata) {
          MetamodelImpl metaModel =
              (MetamodelImpl) kunderaMetadata.getApplicationMetadata().getMetamodel(metadata.getPersistenceUnit());
          EntityType entityType = metaModel.entity(metadata.getEntityClazz());
  
          Iterator<Row> rowIter = rSet.iterator();
          List results = new ArrayList();
  
          Map<String, Object> relationalValues = new HashMap<String, Object>();
  
          while (rowIter.hasNext()) {
              Object entity = null;
              Row row = rowIter.next();
              populateObjectFromRow(metadata, metaModel, entityType, results, relationalValues, entity, row);
          }
          return results;
      }
docs: Iterate and return.
  
  @param rSet
  the r set
  @param entityClazz
  the entity clazz
  @param metadata
  the metadata
  @return the list