code: private <E> List<E> loadQueryDataGFS(EntityMetadata entityMetadata, BasicDBObject mongoQuery,
              BasicDBObject orderBy, int maxResult, int firstResult, boolean isCountQuery)
      {
          List<GridFSDBFile> gfsDBfiles = getGFSDBFiles(mongoQuery, orderBy, entityMetadata.getTableName(), maxResult,
                  firstResult);
  
          if (isCountQuery)
          {
              return (List<E>) Collections.singletonList(gfsDBfiles.size());
          }
  
          List entities = new ArrayList<E>();
          for (GridFSDBFile file : gfsDBfiles)
          {
              populateGFSEntity(entityMetadata, entities, file);
          }
          return entities;
      }
docs: Load query data gfs.
  
  @param <E>
  the element type
  @param entityMetadata
  the entity metadata
  @param mongoQuery
  the mongo query
  @param orderBy
  the order by
  @param maxResult
  the max result
  @param firstResult
  the first result
  @param isCountQuery
  the is count query
  @return the list