Program: 65309
Project: 65309
Buggy source:
/** 
 * INTERNAL: Return if the query is equal to the other. This is used to allow dynamic expression query SQL to be cached.
 */
@Override public boolean equals(Object object){
  if (this == object) {
    return true;
  }
  if ((object == null) || (!getClass().equals(object.getClass()))) {
    return false;
  }
  ObjectLevelReadQuery query=(ObjectLevelReadQuery)object;
  if ((!isExpressionQuery()) || (!isDefaultPropertiesQuery())) {
    return this == object;
  }
  if (!getExpressionBuilder().equals(query.getExpressionBuilder())) {
    return false;
  }
  if (hasJoining()) {
    if (!query.hasJoining()) {
      return false;
    }
    List joinedAttributes=getJoinedAttributeManager().getJoinedAttributeExpressions();
    List otherJoinedAttributes=query.getJoinedAttributeManager().getJoinedAttributeExpressions();
    int size=joinedAttributes.size();
    if (size != otherJoinedAttributes.size()) {
      return false;
    }
    for (int index=0; index < size; index++) {
      if (!joinedAttributes.get(index).equals(otherJoinedAttributes.get(index))) {
        return false;
      }
    }
  }
 else   if (query.hasJoining()) {
    return false;
  }
  if (hasOrderByExpressions()) {
    if (!query.hasOrderByExpressions()) {
      return false;
    }
    List orderBys=getOrderByExpressions();
    List otherOrderBys=query.getOrderByExpressions();
    int size=orderBys.size();
    if (size != otherOrderBys.size()) {
      return false;
    }
    for (int index=0; index < size; index++) {
      if (!orderBys.get(index).equals(otherOrderBys.get(index))) {
        return false;
      }
    }
  }
 else   if (query.hasOrderByExpressions()) {
    return false;
  }
  if (!((this.referenceClass == query.referenceClass) || ((this.referenceClass != null) && this.referenceClass.equals(query.referenceClass)))) {
    return false;
  }
  Expression selectionCriteria=getSelectionCriteria();
  Expression otherSelectionCriteria=query.getSelectionCriteria();
  return ((selectionCriteria == otherSelectionCriteria) || ((selectionCriteria != null) && selectionCriteria.equals(otherSelectionCriteria)));
}

Fixed version (ground truth):
/** 
 * INTERNAL: Return if the query is equal to the other. This is used to allow dynamic expression query SQL to be cached.
 */
@Override public boolean equals(Object object){
  if (this == object) {
    return true;
  }
  if ((object == null) || (!getClass().equals(object.getClass()))) {
    return false;
  }
  ObjectLevelReadQuery query=(ObjectLevelReadQuery)object;
  if ((!isExpressionQuery()) || (!isDefaultPropertiesQuery())) {
    return this == object;
  }
  if (!getExpressionBuilder().equals(query.getExpressionBuilder())) {
    return false;
  }
  if (this.distinctState != query.distinctState) {
    return false;
  }
  if (hasJoining()) {
    if (!query.hasJoining()) {
      return false;
    }
    List joinedAttributes=getJoinedAttributeManager().getJoinedAttributeExpressions();
    List otherJoinedAttributes=query.getJoinedAttributeManager().getJoinedAttributeExpressions();
    int size=joinedAttributes.size();
    if (size != otherJoinedAttributes.size()) {
      return false;
    }
    for (int index=0; index < size; index++) {
      if (!joinedAttributes.get(index).equals(otherJoinedAttributes.get(index))) {
        return false;
      }
    }
  }
 else   if (query.hasJoining()) {
    return false;
  }
  if (hasOrderByExpressions()) {
    if (!query.hasOrderByExpressions()) {
      return false;
    }
    List orderBys=getOrderByExpressions();
    List otherOrderBys=query.getOrderByExpressions();
    int size=orderBys.size();
    if (size != otherOrderBys.size()) {
      return false;
    }
    for (int index=0; index < size; index++) {
      if (!orderBys.get(index).equals(otherOrderBys.get(index))) {
        return false;
      }
    }
  }
 else   if (query.hasOrderByExpressions()) {
    return false;
  }
  if (!((this.referenceClass == query.referenceClass) || ((this.referenceClass != null) && this.referenceClass.equals(query.referenceClass)))) {
    return false;
  }
  Expression selectionCriteria=getSelectionCriteria();
  Expression otherSelectionCriteria=query.getSelectionCriteria();
  return ((selectionCriteria == otherSelectionCriteria) || ((selectionCriteria != null) && selectionCriteria.equals(otherSelectionCriteria)));
}