/**
   * Set the Profile to query.
   *
   * @param x The Profile of the OperatingsystemProfile to query.
   * @param exact to use matches or not
   * @exception DataObjectException If a database access error occurs.
   */
  public void setQueryProfile(jobmatch.data.ProfileDO x, boolean exact)
      throws DataObjectException, QueryException {
    // Remove from cacheHits any DOs that do not meet this
    // setQuery requirement.
    for (int i = 0; i < cacheHits.size() && !hitDb; i++) {
      OperatingsystemProfileDO DO = (OperatingsystemProfileDO) cacheHits.elementAt(i);
      if (null == DO) continue;
      boolean equals = true;

      // DOs are compared by their handles..
      jobmatch.data.ProfileDO m = DO.getProfile();
      if (null == m && null == x) {
        equals = true;
      } else if (null == m || null == x) {
        equals = false;
      } else {
        equals = (DO.getProfile().getOId().toString().equals(x.getOId().toString()));
        if (equals && m != x) {
          System.err.println("\n----------------------------------------------------------");
          System.err.println("m =" + m);
          System.err.println("x =" + x);
        }
      }

      if (!equals) cacheHits.removeElementAt(i--);
    }

    // Also prepare the SQL needed to query the database
    // in case there is no cache, or the query involves other tables.
    if (partialCache || hitDb)
      builder.addWhereClause(
          "Profile", x, "DECIMAL(19,0)", QueryBuilder.NOT_NULL, exactFlag(exact));
  }