Program: 64746
Project: 64746
Buggy source:
/** 
 * Validates the given   {@link AbstractSchemaName}. The tests to perform are: <ul> <li>Check to see the actual entity associated with the entity name does exist.</li> <li>If the abstract schema name is actually a path expression (which can be defined in a subquery but is always parsed as an abstract schema name), then make sure the path expression is resolving to a relationship mapping.</li> </ul>
 * @param expression The {@link AbstractSchemaName} to validate
 * @return <code>true</code> if the entity name was resolved; <code>false</code> otherwise
 */
protected boolean validateAbstractSchemaName(AbstractSchemaName expression){
  String abstractSchemaName=expression.getText();
  Object managedType=helper.getEntityNamed(abstractSchemaName);
  boolean valid=true;
  if (managedType == null) {
    IdentificationVariable identificationVariable=findVirtualIdentificationVariable(expression);
    String variableName=(identificationVariable != null) ? identificationVariable.getText() : null;
    if (ExpressionTools.stringIsNotEmpty(variableName)) {
      Object mapping=helper.resolveMapping(variableName,abstractSchemaName);
      Object type=helper.getMappingType(mapping);
      if (!helper.isTypeResolvable(type)) {
        if (isSubquery(expression)) {
          addProblem(expression,StateFieldPathExpression_NotResolvable,abstractSchemaName);
        }
 else {
          addProblem(expression,AbstractSchemaName_Invalid,abstractSchemaName);
        }
        valid=false;
      }
 else       if (!helper.isRelationshipMapping(mapping)) {
        addProblem(expression,PathExpression_NotRelationshipMapping,abstractSchemaName);
        valid=false;
      }
    }
 else {
      addProblem(expression,AbstractSchemaName_Invalid,abstractSchemaName);
      valid=false;
    }
  }
  return valid;
}

Fixed version (ground truth):
/** 
 * Validates the given   {@link AbstractSchemaName}. The tests to perform are: <ul> <li>Check to see the actual entity associated with the entity name does exist.</li> <li>If the abstract schema name is actually a path expression (which can be defined in a subquery but is always parsed as an abstract schema name), then make sure the path expression is resolving to a relationship mapping.</li> </ul>
 * @param expression The {@link AbstractSchemaName} to validate
 * @return <code>true</code> if the entity name was resolved; <code>false</code> otherwise
 */
protected boolean validateAbstractSchemaName(AbstractSchemaName expression){
  String abstractSchemaName=expression.getText();
  Object managedType=helper.getEntityNamed(abstractSchemaName);
  boolean valid=true;
  if (managedType == null) {
    if (isSubquery(expression)) {
      IdentificationVariable identificationVariable=findVirtualIdentificationVariable(expression);
      String variableName=(identificationVariable != null) ? identificationVariable.getText() : null;
      if (ExpressionTools.stringIsNotEmpty(variableName)) {
        Object mapping=helper.resolveMapping(variableName,abstractSchemaName);
        Object type=helper.getMappingType(mapping);
        if (!helper.isTypeResolvable(type)) {
          addProblem(expression,StateFieldPathExpression_NotResolvable,abstractSchemaName);
          valid=false;
        }
 else         if (!helper.isRelationshipMapping(mapping)) {
          addProblem(expression,PathExpression_NotRelationshipMapping,abstractSchemaName);
          valid=false;
        }
      }
 else {
        addProblem(expression,AbstractSchemaName_Invalid,abstractSchemaName);
        valid=false;
      }
    }
 else {
      addProblem(expression,AbstractSchemaName_Invalid,abstractSchemaName);
      valid=false;
    }
  }
  return valid;
}