code: @Override
      public List<EnhanceEntity> populateRelation(EntityMetadata m, Client client, int maxResults)
      {
          // TODO: maxresults to be taken care after work on pagination.
  
          List<EnhanceEntity> ls = null;
          List<String> relationNames = m.getRelationNames();
          boolean isParent = m.isParent();
          if (!isParent)
          {
              // if it is not a parent.
              String sqlQuery = null;
              if (MetadataUtils.useSecondryIndex(((ClientBase) client).getClientMetadata()))
              {
                  sqlQuery = getSqlQueryFromJPA(m, relationNames, null);
              }
              else
              {
                  // prepare lucene query and find.
                  Set<String> rSet = fetchDataFromLucene(m.getEntityClazz(), client);
                  if (rSet != null && !rSet.isEmpty())
                  {
                      filter = "WHERE";
                  }
                  sqlQuery = getSqlQueryFromJPA(m, relationNames, rSet);
              }
              // call client with relation name list and convert to sql query.
  
              ls = populateEnhanceEntities(m, relationNames, client, sqlQuery);
          }
          else
          {
              if (MetadataUtils.useSecondryIndex(((ClientBase) client).getClientMetadata()))
              {
                  try
                  {
                      List entities = ((HibernateClient) client).find(getSqlQueryFromJPA(m, relationNames, null),
                              new ArrayList<String>(), m);
                      ls = new ArrayList<EnhanceEntity>(entities.size());
                      ls = transform(m, ls, entities);
                  }
                  catch (Exception e)
                  {
                      log.error("Error while executing handleAssociation for RDBMS, Caused by {}.", e);
                      throw new QueryHandlerException(e);
                  }
              }
              else
              {
                  ls = onAssociationUsingLucene(m, client, ls);
              }
          }
  
          return ls;
      }
docs: /*
  (non-Javadoc)
  
  @see
  com.impetus.kundera.persistence.EntityReader#populateRelation(com.impetus
  .kundera.metadata.model.EntityMetadata, java.util.List, boolean,
  com.impetus.kundera.client.Client)