Program: 176099
Project: 176099
Buggy source:
/** 
 * Creates MongoDB Query object from filterClauseQueue.
 * @param m the m
 * @param filterClauseQueue the filter clause queue
 * @param columns
 * @return the basic db object
 */
private BasicDBObject createMongoQuery(EntityMetadata m,Queue filterClauseQueue){
  BasicDBObject query=new BasicDBObject();
  BasicDBObject compositeColumns=new BasicDBObject();
  MetamodelImpl metaModel=(MetamodelImpl)KunderaMetadata.INSTANCE.getApplicationMetadata().getMetamodel(m.getPersistenceUnit());
  for (  Object object : filterClauseQueue) {
    boolean isCompositeColumn=false;
    if (object instanceof FilterClause) {
      FilterClause filter=(FilterClause)object;
      String property=filter.getProperty();
      String condition=filter.getCondition();
      Object value=filter.getValue();
      Field f=null;
      if (((AbstractAttribute)m.getIdAttribute()).getJPAColumnName().equalsIgnoreCase(property)) {
        property="String_Node_Str";
        f=(Field)m.getIdAttribute().getJavaMember();
        if (metaModel.isEmbeddable(m.getIdAttribute().getBindableJavaType()) && value.getClass().isAssignableFrom(f.getType())) {
          EmbeddableType compoundKey=metaModel.embeddable(m.getIdAttribute().getBindableJavaType());
          compositeColumns=MongoDBUtils.getCompoundKeyColumns(m,value,compoundKey);
          isCompositeColumn=true;
          continue;
        }
      }
 else       if (metaModel.isEmbeddable(m.getIdAttribute().getBindableJavaType()) && StringUtils.contains(property,'.')) {
        property=property.substring(property.indexOf("String_Node_Str") + 1);
        isCompositeColumn=true;
      }
 else {
        EntityType entity=metaModel.entity(m.getEntityClazz());
        String discriminatorColumn=((AbstractManagedType)entity).getDiscriminatorColumn();
        if (!property.equals(discriminatorColumn)) {
          String fieldName=m.getFieldName(property);
          f=(Field)entity.getAttribute(fieldName).getJavaMember();
        }
      }
      if (value.getClass().isAssignableFrom(String.class) && f != null && !f.getType().equals(value.getClass())) {
        value=PropertyAccessorFactory.getPropertyAccessor(f).fromString(f.getType().getClass(),value.toString());
      }
      value=MongoDBUtils.populateValue(value,value.getClass());
      if (f != null && f.getType().equals(Point.class)) {
        GeospatialQuery geospatialQueryimpl=GeospatialQueryFactory.getGeospatialQueryImplementor(condition,value);
        query=(BasicDBObject)geospatialQueryimpl.createGeospatialQuery(property,value,query);
      }
 else {
        if (condition.equals("String_Node_Str")) {
          if (isCompositeColumn) {
            compositeColumns.put(property,value);
          }
 else {
            query.append(property,value);
          }
        }
 else         if (condition.equalsIgnoreCase("String_Node_Str")) {
          if (isCompositeColumn) {
            compositeColumns.put(property,value);
          }
 else {
            query.append(property,value);
          }
        }
 else         if (condition.equalsIgnoreCase("String_Node_Str")) {
          if (isCompositeColumn) {
            compositeColumns.put(property,new BasicDBObject("String_Node_Str",value));
          }
 else {
            if (query.containsField(property)) {
              query.get(property);
              query.put(property,((BasicDBObject)query.get(property)).append("String_Node_Str",value));
            }
 else {
              query.append(property,new BasicDBObject("String_Node_Str",value));
            }
          }
        }
 else         if (condition.equalsIgnoreCase("String_Node_Str")) {
          if (isCompositeColumn) {
            compositeColumns.put(property,new BasicDBObject("String_Node_Str",value));
          }
 else {
            if (query.containsField(property)) {
              query.get(property);
              query.put(property,((BasicDBObject)query.get(property)).append("String_Node_Str",value));
            }
 else {
              query.append(property,new BasicDBObject("String_Node_Str",value));
            }
          }
        }
 else         if (condition.equalsIgnoreCase("String_Node_Str")) {
          if (isCompositeColumn) {
            compositeColumns.put(property,new BasicDBObject("String_Node_Str",value));
          }
 else {
            if (query.containsField(property)) {
              query.get(property);
              query.put(property,((BasicDBObject)query.get(property)).append("String_Node_Str",value));
            }
 else {
              query.append(property,new BasicDBObject("String_Node_Str",value));
            }
          }
        }
 else         if (condition.equalsIgnoreCase("String_Node_Str")) {
          if (isCompositeColumn) {
            compositeColumns.put(property,new BasicDBObject("String_Node_Str",value));
          }
 else {
            if (query.containsField(property)) {
              query.get(property);
              query.put(property,((BasicDBObject)query.get(property)).append("String_Node_Str",value));
            }
 else {
              query.append(property,new BasicDBObject("String_Node_Str",value));
            }
          }
        }
      }
    }
  }
  if (!compositeColumns.isEmpty()) {
    query.append("String_Node_Str",compositeColumns);
  }
  return query;
}

Fixed version (ground truth):
/** 
 * Creates MongoDB Query object from filterClauseQueue.
 * @param m the m
 * @param filterClauseQueue the filter clause queue
 * @param columns
 * @return the basic db object
 */
private BasicDBObject createMongoQuery(EntityMetadata m,Queue filterClauseQueue){
  BasicDBObject query=new BasicDBObject();
  BasicDBObject compositeColumns=new BasicDBObject();
  MetamodelImpl metaModel=(MetamodelImpl)KunderaMetadata.INSTANCE.getApplicationMetadata().getMetamodel(m.getPersistenceUnit());
  for (  Object object : filterClauseQueue) {
    boolean isCompositeColumn=false;
    if (object instanceof FilterClause) {
      FilterClause filter=(FilterClause)object;
      String property=filter.getProperty();
      String condition=filter.getCondition();
      Object value=filter.getValue();
      Field f=null;
      if (((AbstractAttribute)m.getIdAttribute()).getJPAColumnName().equalsIgnoreCase(property)) {
        property="String_Node_Str";
        f=(Field)m.getIdAttribute().getJavaMember();
        if (metaModel.isEmbeddable(m.getIdAttribute().getBindableJavaType()) && value.getClass().isAssignableFrom(f.getType())) {
          EmbeddableType compoundKey=metaModel.embeddable(m.getIdAttribute().getBindableJavaType());
          compositeColumns=MongoDBUtils.getCompoundKeyColumns(m,value,compoundKey);
          isCompositeColumn=true;
          continue;
        }
      }
 else       if (metaModel.isEmbeddable(m.getIdAttribute().getBindableJavaType()) && StringUtils.contains(property,'.')) {
        property=property.substring(property.indexOf("String_Node_Str") + 1);
        isCompositeColumn=true;
      }
 else       if (StringUtils.contains(property,'.')) {
        EntityType entity=metaModel.entity(m.getEntityClazz());
        StringTokenizer tokenizer=new StringTokenizer(property,"String_Node_Str");
        String embeddedAttributeAsStr=tokenizer.nextToken();
        String embeddableAttributeAsStr=tokenizer.nextToken();
        Attribute embeddedAttribute=entity.getAttribute(embeddedAttributeAsStr);
        EmbeddableType embeddableEntity=metaModel.embeddable(((AbstractAttribute)embeddedAttribute).getBindableJavaType());
        f=(Field)embeddableEntity.getAttribute(embeddableAttributeAsStr).getJavaMember();
      }
 else {
        EntityType entity=metaModel.entity(m.getEntityClazz());
        String discriminatorColumn=((AbstractManagedType)entity).getDiscriminatorColumn();
        if (!property.equals(discriminatorColumn)) {
          String fieldName=m.getFieldName(property);
          f=(Field)entity.getAttribute(fieldName).getJavaMember();
        }
      }
      if (value.getClass().isAssignableFrom(String.class) && f != null && !f.getType().equals(value.getClass())) {
        value=PropertyAccessorFactory.getPropertyAccessor(f).fromString(f.getType().getClass(),value.toString());
      }
      value=MongoDBUtils.populateValue(value,value.getClass());
      if (f != null && f.getType().equals(Point.class)) {
        GeospatialQuery geospatialQueryimpl=GeospatialQueryFactory.getGeospatialQueryImplementor(condition,value);
        query=(BasicDBObject)geospatialQueryimpl.createGeospatialQuery(property,value,query);
      }
 else {
        if (condition.equals("String_Node_Str")) {
          if (isCompositeColumn) {
            compositeColumns.put(property,value);
          }
 else {
            query.append(property,value);
          }
        }
 else         if (condition.equalsIgnoreCase("String_Node_Str")) {
          if (isCompositeColumn) {
            compositeColumns.put(property,value);
          }
 else {
            query.append(property,value);
          }
        }
 else         if (condition.equalsIgnoreCase("String_Node_Str")) {
          if (isCompositeColumn) {
            compositeColumns.put(property,new BasicDBObject("String_Node_Str",value));
          }
 else {
            if (query.containsField(property)) {
              query.get(property);
              query.put(property,((BasicDBObject)query.get(property)).append("String_Node_Str",value));
            }
 else {
              query.append(property,new BasicDBObject("String_Node_Str",value));
            }
          }
        }
 else         if (condition.equalsIgnoreCase("String_Node_Str")) {
          if (isCompositeColumn) {
            compositeColumns.put(property,new BasicDBObject("String_Node_Str",value));
          }
 else {
            if (query.containsField(property)) {
              query.get(property);
              query.put(property,((BasicDBObject)query.get(property)).append("String_Node_Str",value));
            }
 else {
              query.append(property,new BasicDBObject("String_Node_Str",value));
            }
          }
        }
 else         if (condition.equalsIgnoreCase("String_Node_Str")) {
          if (isCompositeColumn) {
            compositeColumns.put(property,new BasicDBObject("String_Node_Str",value));
          }
 else {
            if (query.containsField(property)) {
              query.get(property);
              query.put(property,((BasicDBObject)query.get(property)).append("String_Node_Str",value));
            }
 else {
              query.append(property,new BasicDBObject("String_Node_Str",value));
            }
          }
        }
 else         if (condition.equalsIgnoreCase("String_Node_Str")) {
          if (isCompositeColumn) {
            compositeColumns.put(property,new BasicDBObject("String_Node_Str",value));
          }
 else {
            if (query.containsField(property)) {
              query.get(property);
              query.put(property,((BasicDBObject)query.get(property)).append("String_Node_Str",value));
            }
 else {
              query.append(property,new BasicDBObject("String_Node_Str",value));
            }
          }
        }
      }
    }
  }
  if (!compositeColumns.isEmpty()) {
    query.append("String_Node_Str",compositeColumns);
  }
  return query;
}