Program: 175962
Project: 175962
Buggy source:
/** 
 * Build the aggregation parameters.
 * @param group
 * @param expression
 * @param metadata
 * @param entityType
 */
private void buildAggregation(DBObject group,Expression expression,EntityMetadata metadata,EntityType entityType,boolean hasLob){
  if (expression instanceof AggregateFunction) {
    AggregateFunction aggregateFunction=(AggregateFunction)expression;
    String identifier=aggregateFunction.getIdentifier().toLowerCase();
    Expression child=aggregateFunction.getExpression();
    if (child instanceof StateFieldPathExpression) {
      StateFieldPathExpression sfpExp=(StateFieldPathExpression)child;
      String columnName=getColumnName(metadata,entityType,sfpExp.toActualText());
      String actualColumnName=columnName;
      if (hasLob) {
        actualColumnName="String_Node_Str" + columnName;
      }
 else       if (metadata.getIdAttribute().equals(entityType.getAttribute(columnName))) {
        actualColumnName="String_Node_Str";
      }
      BasicDBObject item=new BasicDBObject("String_Node_Str" + identifier,"String_Node_Str" + actualColumnName);
      group.put(identifier + "String_Node_Str" + columnName,item);
    }
 else     if (expression instanceof CountFunction) {
      group.put("String_Node_Str",new BasicDBObject("String_Node_Str",1));
    }
  }
 else   if (expression instanceof CollectionExpression) {
    for (    Expression child : expression.children()) {
      buildAggregation(group,child,metadata,entityType,hasLob);
    }
  }
 else   if (expression instanceof StateFieldPathExpression) {
    StateFieldPathExpression sfpExp=(StateFieldPathExpression)expression;
    BasicDBObject idObject;
    Object existing=group.get("String_Node_Str");
    if (existing != null) {
      idObject=(BasicDBObject)existing;
    }
 else {
      idObject=new BasicDBObject();
      group.put("String_Node_Str",idObject);
    }
    String columnName=getColumnName(metadata,entityType,sfpExp.toActualText());
    String actualColumnName=columnName;
    if (hasLob) {
      actualColumnName="String_Node_Str" + columnName;
    }
    idObject.put(columnName,"String_Node_Str" + actualColumnName);
  }
}

Fixed version (ground truth):
/** 
 * Build the aggregation parameters.
 * @param group
 * @param expression
 * @param metadata
 * @param entityType
 */
private void buildAggregation(DBObject group,Expression expression,EntityMetadata metadata,EntityType entityType,boolean hasLob){
  if (expression instanceof AggregateFunction) {
    AggregateFunction aggregateFunction=(AggregateFunction)expression;
    String identifier=aggregateFunction.getIdentifier().toLowerCase();
    Expression child=aggregateFunction.getExpression();
    if (child instanceof StateFieldPathExpression) {
      StateFieldPathExpression sfpExp=(StateFieldPathExpression)child;
      String columnName=getColumnName(metadata,entityType,sfpExp.toActualText());
      String actualColumnName=columnName;
      if (hasLob) {
        actualColumnName="String_Node_Str" + columnName;
      }
 else       if (metadata.getIdAttribute().equals(entityType.getAttribute(metadata.getFieldName(columnName)))) {
        actualColumnName="String_Node_Str";
      }
      BasicDBObject item=new BasicDBObject("String_Node_Str" + identifier,"String_Node_Str" + actualColumnName);
      group.put(identifier + "String_Node_Str" + columnName,item);
    }
 else     if (expression instanceof CountFunction) {
      group.put("String_Node_Str",new BasicDBObject("String_Node_Str",1));
    }
  }
 else   if (expression instanceof CollectionExpression) {
    for (    Expression child : expression.children()) {
      buildAggregation(group,child,metadata,entityType,hasLob);
    }
  }
 else   if (expression instanceof StateFieldPathExpression) {
    StateFieldPathExpression sfpExp=(StateFieldPathExpression)expression;
    BasicDBObject idObject;
    Object existing=group.get("String_Node_Str");
    if (existing != null) {
      idObject=(BasicDBObject)existing;
    }
 else {
      idObject=new BasicDBObject();
      group.put("String_Node_Str",idObject);
    }
    String columnName=getColumnName(metadata,entityType,sfpExp.toActualText());
    String actualColumnName=columnName;
    if (hasLob) {
      actualColumnName="String_Node_Str" + columnName;
    }
    idObject.put(columnName,"String_Node_Str" + actualColumnName);
  }
}