Program: 63563
Project: 63563
Buggy source:
/** 
 * INTERNAL: Extract the values from the expression into the row. Ensure that the query is querying the exact primary key.
 * @param requireExactMatch refers to the primary key extracted gaurenteeing the result,if not exact it is a heuristic and the cache hit will be conformed to the expression after the lookup Return false if not on the primary key.
 */
@Override public boolean extractValues(boolean primaryKeyOnly,boolean requireExactMatch,ClassDescriptor descriptor,AbstractRecord primaryKeyRow,AbstractRecord translationRow){
  if (requireExactMatch && (!(this.operator.getSelector() == ExpressionOperator.Equal))) {
    return false;
  }
  if ((!requireExactMatch) && (this.operator.getSelector() == ExpressionOperator.In)) {
    return false;
  }
  DatabaseField field=null;
  Object value=null;
  if (this.secondChild.isConstantExpression()) {
    value=((ConstantExpression)this.secondChild).getValue();
  }
 else   if (this.secondChild.isParameterExpression() && (translationRow != null)) {
    value=translationRow.get(((ParameterExpression)this.secondChild).getField());
  }
 else   if (this.firstChild.isConstantExpression()) {
    value=((ConstantExpression)this.firstChild).getValue();
  }
 else   if (this.firstChild.isParameterExpression() && (translationRow != null)) {
    value=translationRow.get(((ParameterExpression)this.firstChild).getField());
  }
  if (value == null) {
    return false;
  }
  if (this.firstChild.isFieldExpression()) {
    FieldExpression child=(FieldExpression)this.firstChild;
    if (!child.getBaseExpression().isExpressionBuilder()) {
      return false;
    }
    field=child.getField();
  }
 else   if (this.firstChild.isQueryKeyExpression()) {
    QueryKeyExpression child=(QueryKeyExpression)this.firstChild;
    if (!child.getBaseExpression().isExpressionBuilder()) {
      return false;
    }
    DatabaseMapping mapping=descriptor.getObjectBuilder().getMappingForAttributeName(child.getName());
    if (mapping != null) {
      if (primaryKeyOnly && !mapping.isPrimaryKeyMapping()) {
        return false;
      }
      if (mapping.isObjectReferenceMapping() || mapping.isAggregateObjectMapping()) {
        mapping.writeFromAttributeIntoRow(value,primaryKeyRow,getSession());
        return true;
      }
      if (!mapping.isAbstractColumnMapping()) {
        return false;
      }
      field=((AbstractColumnMapping)mapping).getField();
    }
 else {
      field=descriptor.getObjectBuilder().getFieldForQueryKeyName(child.getName());
    }
  }
 else   if (this.secondChild.isFieldExpression()) {
    FieldExpression child=(FieldExpression)this.secondChild;
    if (!child.getBaseExpression().isExpressionBuilder()) {
      return false;
    }
    field=child.getField();
  }
 else   if (this.secondChild.isQueryKeyExpression()) {
    QueryKeyExpression child=(QueryKeyExpression)this.secondChild;
    if (!child.getBaseExpression().isExpressionBuilder()) {
      return false;
    }
    DatabaseMapping mapping=descriptor.getObjectBuilder().getMappingForAttributeName(child.getName());
    if (mapping != null) {
      if (primaryKeyOnly && !mapping.isPrimaryKeyMapping()) {
        return false;
      }
      if (mapping.isObjectReferenceMapping() || mapping.isAggregateObjectMapping()) {
        mapping.writeFromAttributeIntoRow(value,primaryKeyRow,getSession());
        return true;
      }
      if (!mapping.isAbstractColumnMapping()) {
        return false;
      }
      field=((AbstractColumnMapping)mapping).getField();
    }
 else {
      field=descriptor.getObjectBuilder().getFieldForQueryKeyName(child.getName());
    }
  }
 else {
    return false;
  }
  if ((field == null) || (primaryKeyOnly && !descriptor.getPrimaryKeyFields().contains(field))) {
    return false;
  }
  primaryKeyRow.put(field,value);
  return true;
}

Fixed version (ground truth):
/** 
 * INTERNAL: Extract the values from the expression into the row. Ensure that the query is querying the exact primary key.
 * @param requireExactMatch refers to the primary key extracted gaurenteeing the result,if not exact it is a heuristic and the cache hit will be conformed to the expression after the lookup Return false if not on the primary key.
 */
@Override public boolean extractValues(boolean primaryKeyOnly,boolean requireExactMatch,ClassDescriptor descriptor,AbstractRecord primaryKeyRow,AbstractRecord translationRow){
  if (requireExactMatch && (!(this.operator.getSelector() == ExpressionOperator.Equal))) {
    return false;
  }
  if ((!requireExactMatch) && (this.operator.getSelector() == ExpressionOperator.In)) {
    return false;
  }
  DatabaseField field=null;
  Object value=null;
  if (this.secondChild.isConstantExpression()) {
    value=((ConstantExpression)this.secondChild).getValue();
  }
 else   if (this.secondChild.isParameterExpression() && (translationRow != null)) {
    value=translationRow.get(((ParameterExpression)this.secondChild).getField());
  }
 else   if (this.firstChild.isConstantExpression()) {
    value=((ConstantExpression)this.firstChild).getValue();
  }
 else   if (this.firstChild.isParameterExpression() && (translationRow != null)) {
    value=translationRow.get(((ParameterExpression)this.firstChild).getField());
  }
  if (value == null) {
    return false;
  }
  ClassDescriptor descriptorForChild=null;
  if (this.firstChild.isFieldExpression()) {
    FieldExpression child=(FieldExpression)this.firstChild;
    if (!child.getBaseExpression().isExpressionBuilder()) {
      return false;
    }
    field=child.getField();
  }
 else   if (this.firstChild.isQueryKeyExpression()) {
    QueryKeyExpression child=(QueryKeyExpression)this.firstChild;
    if (!child.getBaseExpression().isExpressionBuilder()) {
      return false;
    }
    descriptorForChild=((ExpressionBuilder)child.getBaseExpression()).getDescriptor();
    if (descriptorForChild == null) {
      descriptorForChild=descriptor;
    }
    DatabaseMapping mapping=descriptorForChild.getObjectBuilder().getMappingForAttributeName(child.getName());
    if (mapping != null) {
      if (primaryKeyOnly && !mapping.isPrimaryKeyMapping()) {
        return false;
      }
      if (mapping.isObjectReferenceMapping() || mapping.isAggregateObjectMapping()) {
        mapping.writeFromAttributeIntoRow(value,primaryKeyRow,getSession());
        return true;
      }
      if (!mapping.isAbstractColumnMapping()) {
        return false;
      }
      field=((AbstractColumnMapping)mapping).getField();
    }
 else {
      field=descriptorForChild.getObjectBuilder().getFieldForQueryKeyName(child.getName());
    }
  }
 else   if (this.secondChild.isFieldExpression()) {
    FieldExpression child=(FieldExpression)this.secondChild;
    if (!child.getBaseExpression().isExpressionBuilder()) {
      return false;
    }
    field=child.getField();
  }
 else   if (this.secondChild.isQueryKeyExpression()) {
    QueryKeyExpression child=(QueryKeyExpression)this.secondChild;
    if (!child.getBaseExpression().isExpressionBuilder()) {
      return false;
    }
    descriptorForChild=((ExpressionBuilder)child.getBaseExpression()).getDescriptor();
    if (descriptorForChild == null) {
      descriptorForChild=descriptor;
    }
    DatabaseMapping mapping=descriptorForChild.getObjectBuilder().getMappingForAttributeName(child.getName());
    if (mapping != null) {
      if (primaryKeyOnly && !mapping.isPrimaryKeyMapping()) {
        return false;
      }
      if (mapping.isObjectReferenceMapping() || mapping.isAggregateObjectMapping()) {
        mapping.writeFromAttributeIntoRow(value,primaryKeyRow,getSession());
        return true;
      }
      if (!mapping.isAbstractColumnMapping()) {
        return false;
      }
      field=((AbstractColumnMapping)mapping).getField();
    }
 else {
      field=descriptorForChild.getObjectBuilder().getFieldForQueryKeyName(child.getName());
    }
  }
 else {
    return false;
  }
  if (field == null) {
    return false;
  }
  if (primaryKeyOnly && !descriptor.getPrimaryKeyFields().contains(field)) {
    if (descriptorForChild != null && descriptorForChild != descriptor && descriptorForChild.getPrimaryKeyFields().contains(field)) {
      return true;
    }
 else {
      return false;
    }
  }
  if (primaryKeyRow.get(field) != null) {
    return false;
  }
  primaryKeyRow.put(field,value);
  return true;
}