code: private void populateEntity(EntityMetadata entityMetadata, List entities, DBObject fetchedDocument)
      {
  
          // handler.getEntityFromGFSDBFile(entityClazz, entity, m, outputFile,
          // kunderaMetadata)
          Map<String, Object> relationValue = null;
          if (fetchedDocument != null)
          {
              MetamodelImpl metaModel = (MetamodelImpl) kunderaMetadata.getApplicationMetadata().getMetamodel(
                      entityMetadata.getPersistenceUnit());
  
              EntityType entityType = metaModel.entity(entityMetadata.getEntityClazz());
  
              List<AbstractManagedType> subManagedType = ((AbstractManagedType) entityType).getSubManagedType();
  
              EntityMetadata subEntityMetadata = null;
              Object enhancedEntity = null;
              if (!subManagedType.isEmpty())
              {
                  for (AbstractManagedType subEntity : subManagedType)
                  {
                      String discColumn = subEntity.getDiscriminatorColumn();
                      String disColValue = subEntity.getDiscriminatorValue();
                      Object value = fetchedDocument.get(discColumn);
                      if (value != null && value.toString().equals(disColValue))
                      {
                          subEntityMetadata = KunderaMetadataManager.getEntityMetadata(kunderaMetadata,
                                  subEntity.getJavaType());
                          break;
                      }
                  }
                  enhancedEntity = instantiateEntity(subEntityMetadata.getEntityClazz(), enhancedEntity);
                  relationValue = handler.getEntityFromDocument(subEntityMetadata.getEntityClazz(), enhancedEntity,
                          subEntityMetadata, fetchedDocument, subEntityMetadata.getRelationNames(), relationValue,
                          kunderaMetadata);
  
              }
              else
              {
                  enhancedEntity = instantiateEntity(entityMetadata.getEntityClazz(), enhancedEntity);
                  relationValue = handler.getEntityFromDocument(entityMetadata.getEntityClazz(), enhancedEntity,
                          entityMetadata, fetchedDocument, entityMetadata.getRelationNames(), relationValue,
                          kunderaMetadata);
              }
  
              if (relationValue != null && !relationValue.isEmpty())
              {
                  enhancedEntity = new EnhanceEntity(enhancedEntity, PropertyAccessorHelper.getId(enhancedEntity,
                          entityMetadata), relationValue);
              }
  
              if (enhancedEntity != null)
              {
                  entities.add(enhancedEntity);
              }
          }
      }
docs: Populate entity.
  
  @param entityMetadata
  the entity metadata
  @param entities
  the entities
  @param fetchedDocument
  the fetched document