Program: 64282
Project: 64282
Buggy source:
/** 
 * INTERNAL: For CR#2456 if this is part of an objExp.equal(objExp), do not need to add additional expressions to normalizer both times, and the foreign key join replaces the equal expression.
 */
public Expression normalize(ExpressionNormalizer normalizer,Expression base,List<Expression> foreignKeyJoinPointer){
  if (this.hasBeenNormalized) {
    return this;
  }
  Expression clonedExpression=checkJoinForSubSelectWithParent(normalizer);
  if (clonedExpression != null) {
    return clonedExpression;
  }
  super.normalize(normalizer);
  DatabaseMapping mapping=getMapping();
  SQLSelectStatement statement=normalizer.getStatement();
  if ((mapping != null) && mapping.isDirectToXMLTypeMapping()) {
    statement.setRequiresAliases(true);
  }
  if (isAttribute()) {
    return this;
  }
  ReadQuery query=normalizer.getStatement().getQuery();
  if ((query != null) && query.shouldCacheQueryResults()) {
    if ((mapping != null) && (mapping.getReferenceDescriptor().getJavaClass() != null)) {
      query.getQueryResultsCachePolicy().getInvalidationClasses().add(mapping.getReferenceDescriptor().getJavaClass());
    }
 else {
      QueryKey queryKey=getQueryKeyOrNull();
      if ((queryKey != null) && queryKey.isForeignReferenceQueryKey()) {
        query.getQueryResultsCachePolicy().getInvalidationClasses().add(((ForeignReferenceQueryKey)queryKey).getReferenceClass());
      }
    }
  }
  if ((mapping != null) && (mapping.isReferenceMapping() || mapping.isStructureMapping())) {
    statement.setRequiresAliases(true);
    return this;
  }
  if (shouldQueryToManyRelationship() && (!statement.isDistinctComputed()) && (!statement.isAggregateSelect())) {
    statement.useDistinct();
  }
  if ((mapping != null) && mapping.isNestedTableMapping()) {
    if (!shouldQueryToManyRelationship()) {
      return this;
    }
    statement.dontUseDistinct();
  }
  if (this.onClause != null) {
    this.onClause=this.onClause.normalize(normalizer);
  }
  Expression mappingExpression=mappingCriteria(base);
  if (mappingExpression != null) {
    mappingExpression=mappingExpression.normalize(normalizer);
  }
  if (mappingExpression != null) {
    if (shouldUseOuterJoin() && (getSession().getPlatform().isInformixOuterJoin())) {
      statement.getOuterJoinExpressions().add(this);
      statement.getOuterJoinedMappingCriteria().add(mappingExpression);
      normalizer.addAdditionalExpression(mappingExpression.and(additionalExpressionCriteria()));
      return this;
    }
 else     if ((shouldUseOuterJoin() && (!getSession().getPlatform().shouldPrintOuterJoinInWhereClause())) || (!getSession().getPlatform().shouldPrintInnerJoinInWhereClause())) {
      statement.getOuterJoinExpressions().add(this);
      statement.getOuterJoinedMappingCriteria().add(mappingExpression);
      statement.getOuterJoinedAdditionalJoinCriteria().add(additionalExpressionCriteriaMap());
      statement.getDescriptorsForMultitableInheritanceOnly().add(null);
      if ((getDescriptor() != null) && (getDescriptor().getHistoryPolicy() != null)) {
        Expression historyOnClause=getDescriptor().getHistoryPolicy().additionalHistoryExpression(this,this,0);
        if (getOnClause() != null) {
          setOnClause(getOnClause().and(historyOnClause));
        }
 else {
          setOnClause(historyOnClause);
        }
      }
      return this;
    }
 else     if (isUsingOuterJoinForMultitableInheritance() && (!getSession().getPlatform().shouldPrintOuterJoinInWhereClause())) {
      statement.getOuterJoinExpressions().add(null);
      statement.getOuterJoinedMappingCriteria().add(null);
      statement.getOuterJoinedAdditionalJoinCriteria().add(additionalExpressionCriteriaMap());
      statement.getDescriptorsForMultitableInheritanceOnly().add(mapping.getReferenceDescriptor());
    }
    if (foreignKeyJoinPointer != null) {
      foreignKeyJoinPointer.add(mappingExpression.and(this.onClause));
    }
 else {
      normalizer.addAdditionalExpression(mappingExpression.and(additionalExpressionCriteria()).and(this.onClause));
    }
  }
  return this;
}

Fixed version (ground truth):
/** 
 * INTERNAL: For CR#2456 if this is part of an objExp.equal(objExp), do not need to add additional expressions to normalizer both times, and the foreign key join replaces the equal expression.
 */
public Expression normalize(ExpressionNormalizer normalizer,Expression base,List<Expression> foreignKeyJoinPointer){
  if (this.hasBeenNormalized) {
    return this;
  }
  Expression clonedExpression=checkJoinForSubSelectWithParent(normalizer,base,foreignKeyJoinPointer);
  if (clonedExpression != null) {
    return clonedExpression;
  }
  super.normalize(normalizer);
  DatabaseMapping mapping=getMapping();
  SQLSelectStatement statement=normalizer.getStatement();
  if ((mapping != null) && mapping.isDirectToXMLTypeMapping()) {
    statement.setRequiresAliases(true);
  }
  if (isAttribute()) {
    return this;
  }
  ReadQuery query=normalizer.getStatement().getQuery();
  if ((query != null) && query.shouldCacheQueryResults()) {
    if ((mapping != null) && (mapping.getReferenceDescriptor().getJavaClass() != null)) {
      query.getQueryResultsCachePolicy().getInvalidationClasses().add(mapping.getReferenceDescriptor().getJavaClass());
    }
 else {
      QueryKey queryKey=getQueryKeyOrNull();
      if ((queryKey != null) && queryKey.isForeignReferenceQueryKey()) {
        query.getQueryResultsCachePolicy().getInvalidationClasses().add(((ForeignReferenceQueryKey)queryKey).getReferenceClass());
      }
    }
  }
  if ((mapping != null) && (mapping.isReferenceMapping() || mapping.isStructureMapping())) {
    statement.setRequiresAliases(true);
    return this;
  }
  if (shouldQueryToManyRelationship() && (!statement.isDistinctComputed()) && (!statement.isAggregateSelect())) {
    statement.useDistinct();
  }
  if ((mapping != null) && mapping.isNestedTableMapping()) {
    if (!shouldQueryToManyRelationship()) {
      return this;
    }
    statement.dontUseDistinct();
  }
  if (this.onClause != null) {
    this.onClause=this.onClause.normalize(normalizer);
  }
  Expression mappingExpression=mappingCriteria(base);
  if (mappingExpression != null) {
    mappingExpression=mappingExpression.normalize(normalizer);
  }
  if (mappingExpression != null) {
    if (shouldUseOuterJoin() && (getSession().getPlatform().isInformixOuterJoin())) {
      statement.getOuterJoinExpressions().add(this);
      statement.getOuterJoinedMappingCriteria().add(mappingExpression);
      normalizer.addAdditionalExpression(mappingExpression.and(additionalExpressionCriteria()));
      return this;
    }
 else     if ((shouldUseOuterJoin() && (!getSession().getPlatform().shouldPrintOuterJoinInWhereClause())) || (!getSession().getPlatform().shouldPrintInnerJoinInWhereClause())) {
      statement.getOuterJoinExpressions().add(this);
      statement.getOuterJoinedMappingCriteria().add(mappingExpression);
      statement.getOuterJoinedAdditionalJoinCriteria().add(additionalExpressionCriteriaMap());
      statement.getDescriptorsForMultitableInheritanceOnly().add(null);
      if ((getDescriptor() != null) && (getDescriptor().getHistoryPolicy() != null)) {
        Expression historyOnClause=getDescriptor().getHistoryPolicy().additionalHistoryExpression(this,this,0);
        if (getOnClause() != null) {
          setOnClause(getOnClause().and(historyOnClause));
        }
 else {
          setOnClause(historyOnClause);
        }
      }
      return this;
    }
 else     if (isUsingOuterJoinForMultitableInheritance() && (!getSession().getPlatform().shouldPrintOuterJoinInWhereClause())) {
      statement.getOuterJoinExpressions().add(null);
      statement.getOuterJoinedMappingCriteria().add(null);
      statement.getOuterJoinedAdditionalJoinCriteria().add(additionalExpressionCriteriaMap());
      statement.getDescriptorsForMultitableInheritanceOnly().add(mapping.getReferenceDescriptor());
    }
    if (foreignKeyJoinPointer != null) {
      foreignKeyJoinPointer.add(mappingExpression.and(this.onClause));
    }
 else {
      normalizer.addAdditionalExpression(mappingExpression.and(additionalExpressionCriteria()).and(this.onClause));
    }
  }
  return this;
}