Program: 176747
Project: 176747
Buggy source:
/** 
 * Populate via thrift.
 * @param m the m
 * @param entity the entity
 * @param entityType the entity type
 * @param relationNames the relation names
 * @param relations the relations
 * @param thriftColumnName the thrift column name
 * @param thriftColumnValue the thrift column value
 */
private void populateViaThrift(EntityMetadata m,Object entity,EntityType entityType,List<String> relationNames,Map<String,Object> relations,String thriftColumnName,Object thriftColumnValue){
  if (relationNames == null || !relationNames.contains(thriftColumnName)) {
    if (thriftColumnValue != null) {
      String fieldName=m.getFieldName(thriftColumnName);
      Attribute attribute=fieldName != null ? entityType.getAttribute(fieldName) : null;
      if (attribute != null) {
        setFieldValue(entity,thriftColumnValue,attribute);
      }
 else {
        MetamodelImpl metaModel=(MetamodelImpl)KunderaMetadata.INSTANCE.getApplicationMetadata().getMetamodel(m.getPersistenceUnit());
        if (metaModel.isEmbeddable(m.getIdAttribute().getBindableJavaType())) {
          EmbeddableType compoundKey=metaModel.embeddable(m.getIdAttribute().getBindableJavaType());
          try {
            Object compoundKeyObject=PropertyAccessorHelper.getObject(entity,(Field)m.getIdAttribute().getJavaMember());
            if (compoundKeyObject == null) {
              compoundKeyObject=m.getIdAttribute().getBindableJavaType().newInstance();
            }
            Set<Attribute> attributes=compoundKey.getAttributes();
            for (            Attribute compoundAttribute : attributes) {
              if (((AbstractAttribute)compoundAttribute).getJPAColumnName().equals(thriftColumnName)) {
                setFieldValueViaCQL(compoundKeyObject,thriftColumnValue,compoundAttribute);
                PropertyAccessorHelper.set(entity,(Field)m.getIdAttribute().getJavaMember(),compoundKeyObject);
                break;
              }
            }
          }
 catch (          IllegalArgumentException iaex) {
          }
catch (          InstantiationException e) {
            e.printStackTrace();
          }
catch (          IllegalAccessException e) {
            e.printStackTrace();
          }
        }
      }
    }
  }
 else {
    if (relationNames != null && relationNames.contains(thriftColumnName) && thriftColumnValue != null) {
      String fieldName=m.getFieldName(thriftColumnName);
      Attribute attribute=fieldName != null ? entityType.getAttribute(fieldName) : null;
      EntityMetadata relationMetadata=KunderaMetadataManager.getEntityMetadata(attribute.getJavaType());
      Object value=PropertyAccessorHelper.getObject(relationMetadata.getIdAttribute().getJavaType(),(byte[])thriftColumnValue);
      relations.put(thriftColumnName,value);
    }
  }
}

Fixed version (ground truth):
/** 
 * Populate via thrift.
 * @param m the m
 * @param entity the entity
 * @param entityType the entity type
 * @param relationNames the relation names
 * @param relations the relations
 * @param thriftColumnName the thrift column name
 * @param thriftColumnValue the thrift column value
 * @throws IllegalAccessException
 * @throws InstantiationException
 */
private Object populateViaThrift(EntityMetadata m,Object entity,EntityType entityType,List<String> relationNames,Map<String,Object> relations,String thriftColumnName,Object thriftColumnValue) throws InstantiationException, IllegalAccessException {
  if (relationNames == null || !relationNames.contains(thriftColumnName)) {
    if (thriftColumnValue != null) {
      String fieldName=m.getFieldName(thriftColumnName);
      Attribute attribute=fieldName != null ? entityType.getAttribute(fieldName) : null;
      if (attribute != null) {
        entity=initialize(m,entity,null);
        setFieldValue(entity,thriftColumnValue,attribute);
      }
 else {
        MetamodelImpl metaModel=(MetamodelImpl)KunderaMetadata.INSTANCE.getApplicationMetadata().getMetamodel(m.getPersistenceUnit());
        if (metaModel.isEmbeddable(m.getIdAttribute().getBindableJavaType())) {
          entity=initialize(m,entity,null);
          EmbeddableType compoundKey=metaModel.embeddable(m.getIdAttribute().getBindableJavaType());
          try {
            Object compoundKeyObject=PropertyAccessorHelper.getObject(entity,(Field)m.getIdAttribute().getJavaMember());
            if (compoundKeyObject == null) {
              compoundKeyObject=m.getIdAttribute().getBindableJavaType().newInstance();
            }
            Set<Attribute> attributes=compoundKey.getAttributes();
            for (            Attribute compoundAttribute : attributes) {
              if (((AbstractAttribute)compoundAttribute).getJPAColumnName().equals(thriftColumnName)) {
                setFieldValueViaCQL(compoundKeyObject,thriftColumnValue,compoundAttribute);
                PropertyAccessorHelper.set(entity,(Field)m.getIdAttribute().getJavaMember(),compoundKeyObject);
                break;
              }
            }
          }
 catch (          IllegalArgumentException iaex) {
          }
catch (          InstantiationException e) {
            e.printStackTrace();
          }
catch (          IllegalAccessException e) {
            e.printStackTrace();
          }
        }
      }
    }
  }
 else {
    if (relationNames != null && relationNames.contains(thriftColumnName) && thriftColumnValue != null) {
      String fieldName=m.getFieldName(thriftColumnName);
      Attribute attribute=fieldName != null ? entityType.getAttribute(fieldName) : null;
      EntityMetadata relationMetadata=KunderaMetadataManager.getEntityMetadata(attribute.getJavaType());
      Object value=PropertyAccessorHelper.getObject(relationMetadata.getIdAttribute().getJavaType(),(byte[])thriftColumnValue);
      relations.put(thriftColumnName,value);
    }
  }
  return entity;
}