code: private Object wrap(Map<String, Object> results, EntityType entityType, Object result, EntityMetadata metadata,
              boolean isIdSet)
      {
  
          Map<String, Object> relations = new HashMap<String, Object>();
          Object key = null;
          Set<Attribute> attributes = entityType.getAttributes();
          for (Attribute attribute : attributes)
          {
              String fieldName = ((AbstractAttribute) attribute).getJPAColumnName();
  
              if (!attribute.isAssociation())
              {
                  Object fieldValue = results.get(fieldName);
  
                  key = onId(key, attribute, fieldValue);
  
                  if (!isIdSet && key != null)
                  {
                      PropertyAccessorHelper.setId(result, metadata, key);
                  }
  
                  fieldValue = onEnum(attribute, fieldValue);
  
                  // TODOO:This has to be corrected. Reason is, in case of execute
                  // query over composite key. It will not work
  
                  setField(result, key, attribute, fieldValue);
              }
  
              if (attribute.isAssociation())
              {
                  Object fieldValue = results.get(fieldName);
                  relations.put(fieldName, fieldValue);
              }
          }
          return relations.isEmpty() ? result : new EnhanceEntity(result, key, relations);
      }
docs: Wrap.
  
  @param results
  the results
  @param entityType
  the entity type
  @param result
  the result
  @param metadata
  the metadata
  @param isIdSet
  the is id set
  @return the object