コード例 #1
0
  /**
   * selects a collection of System_Log objects pre-filled with their User objects.
   *
   * <p>This method is protected by default in order to keep the public api reasonable. You can
   * provide public methods for those you actually need in System_LogPeer.
   *
   * @throws TorqueException Any exceptions caught during processing will be rethrown wrapped into a
   *     TorqueException.
   */
  protected static List doSelectJoinUser(Criteria c) throws TorqueException {
    // Set the correct dbName if it has not been overridden
    // c.getDbName will return the same object if not set to
    // another value so == check is okay and faster
    if (c.getDbName() == Torque.getDefaultDB()) {
      c.setDbName(DATABASE_NAME);
    }

    System_LogPeer.addSelectColumns(c);
    int offset = numColumns + 1;
    UserPeer.addSelectColumns(c);

    c.addJoin(System_LogPeer.USER_ID, UserPeer.USER_ID);

    List rows = BasePeer.doSelect(c);
    List results = new ArrayList();

    for (int i = 0; i < rows.size(); i++) {
      Record row = (Record) rows.get(i);

      Class omClass = System_LogPeer.getOMClass();
      System_Log obj1 = (System_Log) System_LogPeer.row2Object(row, 1, omClass);
      omClass = UserPeer.getOMClass();
      User obj2 = (User) UserPeer.row2Object(row, offset, omClass);

      boolean newObject = true;
      for (int j = 0; j < results.size(); j++) {
        System_Log temp_obj1 = (System_Log) results.get(j);
        User temp_obj2 = (User) temp_obj1.getUser();
        if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) {
          newObject = false;
          temp_obj2.addSystem_Log(obj1);
          break;
        }
      }
      if (newObject) {
        obj2.initSystem_Logs();
        obj2.addSystem_Log(obj1);
      }
      results.add(obj1);
    }
    return results;
  }