code: private Object getFirstResult(KunderaQuery query, String field, SearchHits hits, Class clazz, Metamodel metaModel,
              EntityMetadata entityMetadata)
      {
          Object entity;
  
          if (query.getEntityAlias().equals(field))
          {
              entity = getEntityObjects(clazz, entityMetadata, metaModel.entity(clazz), hits).get(0);
          }
          else
          {
              String jpaField = ((AbstractAttribute) metaModel.entity(clazz).getAttribute(field)).getJPAColumnName();
              entity = query.getSelectStatement().hasGroupByClause() ? hits.getAt(0).sourceAsMap().get(jpaField) : hits
                      .getAt(0).getFields().get(jpaField).getValue();
          }
          return entity;
      }
docs: Gets the first result.
  
  @param query
  the query
  @param field
  the field
  @param hits
  the hits
  @param clazz
  the clazz
  @param metaModel
  the meta model
  @param entityMetadata
  the entity metadata
  @return the first