コード例 #1
0
  /**
   * Gets the join predicate for a sub-query, or branch.
   *
   * <p>Sample query (1) below exemplifies query where join is not required. Sample query (2) below
   * exemplifies query where join is required.
   *
   * <p>1. SELECT ro.* FROM RegistryObject ro WHERE (ro.status == "<status>")
   *
   * <p>2. SELECT ro.* FROM RegistryObject ro, VersionInfo v WHERE ((v.parent = ro.id) AND
   * v.versionName = "1.2");
   *
   * <p>ro = parentAlias v = alias status = filterColumn versionName = filterColumn parent =
   * foreignKeyColumn id = parent.primaryKeyColumn
   *
   * <p>This method provides the (v.parent = ro.id) portion. Filters are added elsewhere
   */
  protected String getJoinPredicate() {
    String joinPredicate = "";

    if ((parentQueryProcessor != null) && (foreignKeyColumn != null)) {
      String parentAlias = parentQueryProcessor.getAlias();
      String parentPrimaryKeyColumn = parentQueryProcessor.getPrimaryKeyColumn();
      String parentJoinPredicate = parentQueryProcessor.getJoinPredicate();

      // Use full version of appendPredicate() to avoid recursion
      joinPredicate =
          appendPredicate(
              joinPredicate,
              parentJoinPredicate,
              alias + "." + foreignKeyColumn + " = " + parentAlias + "." + parentPrimaryKeyColumn);
    }

    return joinPredicate;
  }