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 ; }
Gets the first result .