Ejemplo n.º 1
0
  /**
   * selects a collection of TRoleListType objects pre-filled with their TRole 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 TRoleListTypePeer.
   *
   * @throws TorqueException Any exceptions caught during processing will be rethrown wrapped into a
   *     TorqueException.
   */
  protected static List<TRoleListType> doSelectJoinTRole(Criteria criteria, Connection conn)
      throws TorqueException {
    setDbName(criteria);

    TRoleListTypePeer.addSelectColumns(criteria);
    int offset = numColumns + 1;
    TRolePeer.addSelectColumns(criteria);

    criteria.addJoin(TRoleListTypePeer.PROLE, TRolePeer.PKEY);

    correctBooleans(criteria);

    List<Record> rows;
    if (conn == null) {
      rows = BasePeer.doSelect(criteria);
    } else {
      rows = BasePeer.doSelect(criteria, conn);
    }

    List<TRoleListType> results = new ArrayList<TRoleListType>();

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

      Class omClass = TRoleListTypePeer.getOMClass();
      TRoleListType obj1 = (TRoleListType) TRoleListTypePeer.row2Object(row, 1, omClass);
      omClass = TRolePeer.getOMClass();
      TRole obj2 = (TRole) TRolePeer.row2Object(row, offset, omClass);

      boolean newObject = true;
      for (int j = 0; j < results.size(); j++) {
        TRoleListType temp_obj1 = results.get(j);
        TRole temp_obj2 = (TRole) temp_obj1.getTRole();
        if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) {
          newObject = false;
          temp_obj2.addTRoleListType(obj1);
          break;
        }
      }
      if (newObject) {
        obj2.initTRoleListTypes();
        obj2.addTRoleListType(obj1);
      }
      results.add(obj1);
    }
    return results;
  }