@Override
    public List<EnhanceEntity> populateRelation(EntityMetadata m, Client client, int maxResults)
    {
        if (log.isInfoEnabled())
        {
            log.info("On populate relation via JPQL");
        }
        List<EnhanceEntity> ls = null;
        List<String> relationNames = m.getRelationNames();
        boolean isParent = m.isParent();

        boolean isRowKeyQuery = conditions != null ? conditions.keySet().iterator().next() : false;

        // If Query is not for find by range.
        if (!isRowKeyQuery)
        {
            // If holding associations.
            if (!isParent)
            {
                // In case need to use secondary indexes.
                if (MetadataUtils.useSecondryIndex(((ClientBase) client).getClientMetadata()))
                {
                    ls = ((CassandraClientBase) client).find(m, relationNames, this.conditions.get(isRowKeyQuery),
                            maxResults, null);
                }
                else
                {
                    // prepare lucene query and find.
                    Set<String> rSet = fetchDataFromLucene(m.getEntityClazz(), client);

                    try
                    {
                        ls = (List<EnhanceEntity>) ((CassandraClientBase) client).find(m.getEntityClazz(),
                                relationNames, true, m, rSet.toArray(new Object[] {}));
                    }
                    catch (Exception e)
                    {
                        log.error("Error while executing handleAssociation for cassandra, Caused by: ", e);
                        throw new QueryHandlerException(e);
                    }
                }
            }
            else
            {
                if (MetadataUtils.useSecondryIndex(((ClientBase) client).getClientMetadata()))
                {
                    // in case need to search on secondry columns and it is not
                    // set
                    // to true!
                    ls = ((CassandraClientBase) client).find(this.conditions.get(isRowKeyQuery), m, true,
                            m.getRelationNames(), maxResults, null);
                }
                else
                {
                    ls = onAssociationUsingLucene(m, client, ls);
                }
            }
        }
        else
        {
            ls = handleFindByRange(m, client, ls, conditions, isRowKeyQuery, null, maxResults);
        }
        return ls;
    }
@ Override public List < EnhanceEntity > populateRelation ( EntityMetadata m , Client client , int maxResults ) { if ( log . isInfoEnabled ( ) ) { log . info ( "On populate relation via JPQL" ) ; } List < EnhanceEntity > ls = null ; List < String > relationNames = m . getRelationNames ( ) ; boolean isParent = m . isParent ( ) ; boolean isRowKeyQuery = conditions != null ? conditions . keySet ( ) . iterator ( ) . next ( ) : false ; if ( ! isRowKeyQuery ) { if ( ! isParent ) { if ( MetadataUtils . useSecondryIndex ( ( ( ClientBase ) client ) . getClientMetadata ( ) ) ) { ls = ( ( CassandraClientBase ) client ) . find ( m , relationNames , this . conditions . get ( isRowKeyQuery ) , maxResults , null ) ; } else { Set < String > rSet = fetchDataFromLucene ( m . getEntityClazz ( ) , client ) ; try { ls = ( List < EnhanceEntity > ) ( ( CassandraClientBase ) client ) . find ( m . getEntityClazz ( ) , relationNames , true , m , rSet . toArray ( new Object [ ] { } ) ) ; } catch ( Exception e ) { log . error ( "Error while executing handleAssociation for cassandra, Caused by: " , e ) ; throw new QueryHandlerException ( e ) ; } } } else { if ( MetadataUtils . useSecondryIndex ( ( ( ClientBase ) client ) . getClientMetadata ( ) ) ) { ls = ( ( CassandraClientBase ) client ) . find ( this . conditions . get ( isRowKeyQuery ) , m , true , m . getRelationNames ( ) , maxResults , null ) ; } else { ls = onAssociationUsingLucene ( m , client , ls ) ; } } } else { ls = handleFindByRange ( m , client , ls , conditions , isRowKeyQuery , null , maxResults ) ; } return ls ; }
Method responsible for reading back entity and relations using secondary
indexes(if it holds any relation), else retrieve row keys using lucene.

@param m            entity meta data
@param client            client instance
@param maxResults the max results
@return list of wrapped enhance entities.