Program: 78262
Project: 78262
Buggy source:
/** 
 * Inserts dataset column into the target. Add label or group key if possible
 * @param model column item
 * @param target insert target like cell or ListBandProxy
 * @param targetParent target container like table or list
 * @return to be inserted data item
 * @throws SemanticException
 */
protected static DataItemHandle performInsertDataSetColumn(ResultSetColumnHandle model,Object target,Object targetParent) throws SemanticException {
  DataItemHandle dataHandle=DesignElementFactory.getInstance().newDataItem(null);
  DataSetHandle dataSet=(DataSetHandle)model.getElementHandle();
  dataHandle.setResultSetColumn(model.getColumnName());
  if (targetParent instanceof ReportItemHandle) {
    ReportItemHandle container=(ReportItemHandle)targetParent;
    if (!DEUtil.getDataSetList(container).contains(dataSet)) {
      if (container.getDataSet() == null) {
        container.setDataSet(dataSet);
      }
    }
    GroupHandle groupHandle=getGroupHandle(target);
    if (groupHandle != null) {
      ComputedColumn bindingColumn=StructureFactory.newComputedColumn(groupHandle,model.getColumnName());
      bindingColumn.setDataType(model.getDataType());
      bindingColumn.setExpression(DEUtil.getExpression(model));
      groupHandle.addColumnBinding(bindingColumn,false);
    }
 else {
      ComputedColumn bindingColumn=StructureFactory.newComputedColumn(container,model.getColumnName());
      bindingColumn.setDataType(model.getDataType());
      bindingColumn.setExpression(DEUtil.getExpression(model));
      container.addColumnBinding(bindingColumn,false);
    }
  }
 else {
    ComputedColumn bindingColumn=StructureFactory.newComputedColumn(dataHandle,model.getColumnName());
    bindingColumn.setDataType(model.getDataType());
    bindingColumn.setExpression(DEUtil.getExpression(model));
    dataHandle.addColumnBinding(bindingColumn,false);
    dataHandle.setDataSet(dataSet);
  }
  InsertInLayoutRule rule=new LabelAddRule(target);
  if (rule.canInsert()) {
    LabelHandle label=DesignElementFactory.getInstance().newLabel(null);
    label.setText(model.getColumnName());
    rule.insert(label);
  }
  rule=new GroupKeySetRule(target,model);
  if (rule.canInsert()) {
    rule.insert(model);
  }
  return dataHandle;
}

Fixed version (ground truth):
/** 
 * Inserts dataset column into the target. Add label or group key if possible
 * @param model column item
 * @param target insert target like cell or ListBandProxy
 * @param targetParent target container like table or list
 * @return to be inserted data item
 * @throws SemanticException
 */
protected static DataItemHandle performInsertDataSetColumn(ResultSetColumnHandle model,Object target,Object targetParent) throws SemanticException {
  DataItemHandle dataHandle=DesignElementFactory.getInstance().newDataItem(null);
  DataSetHandle dataSet=(DataSetHandle)model.getElementHandle();
  dataHandle.setResultSetColumn(model.getColumnName());
  boolean bindingExist=false;
  if (targetParent instanceof ReportItemHandle) {
    ComputedColumn bindingColumn=StructureFactory.createComputedColumn();
    bindingColumn.setName(model.getColumnName());
    bindingColumn.setDataType(model.getDataType());
    bindingColumn.setExpression(DEUtil.getExpression(model));
    ReportItemHandle container=(ReportItemHandle)targetParent;
    GroupHandle groupHandle=getGroupHandle(target);
    if (groupHandle != null) {
      for (Iterator iter=groupHandle.getColumnBindings().iterator(); iter.hasNext(); ) {
        ComputedColumnHandle element=(ComputedColumnHandle)iter.next();
        if (element.getStructure().equals(bindingColumn)) {
          bindingExist=true;
          break;
        }
      }
    }
 else {
      for (Iterator iter=container.getColumnBindings().iterator(); iter.hasNext(); ) {
        ComputedColumnHandle element=(ComputedColumnHandle)iter.next();
        if (element.getStructure().equals(bindingColumn)) {
          bindingExist=true;
          break;
        }
      }
    }
  }
  if (!bindingExist) {
    ComputedColumn bindingColumn=StructureFactory.newComputedColumn(dataHandle,model.getColumnName());
    bindingColumn.setDataType(model.getDataType());
    bindingColumn.setExpression(DEUtil.getExpression(model));
    dataHandle.addColumnBinding(bindingColumn,false);
    dataHandle.setDataSet(dataSet);
  }
  InsertInLayoutRule rule=new LabelAddRule(target);
  if (rule.canInsert()) {
    LabelHandle label=DesignElementFactory.getInstance().newLabel(null);
    label.setText(model.getColumnName());
    rule.insert(label);
  }
  rule=new GroupKeySetRule(target,model);
  if (rule.canInsert()) {
    rule.insert(model);
  }
  return dataHandle;
}