Exemplo n.º 1
0
  /**
   * The returned List will contain objects of the default type or objects that inherit from the
   * default.
   *
   * @throws TorqueException Any exceptions caught during processing will be rethrown wrapped into a
   *     TorqueException.
   */
  public static List<TOption> populateObjects(List<Record> records) throws TorqueException {
    List<TOption> results = new ArrayList<TOption>(records.size());

    // populate the object(s)
    for (int i = 0; i < records.size(); i++) {
      Record row = records.get(i);
      results.add(TOptionPeer.row2Object(row, 1, TOptionPeer.getOMClass()));
    }
    return results;
  }
Exemplo n.º 2
0
  /**
   * selects a collection of TOption objects pre-filled with their TBLOB 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 TOptionPeer.
   *
   * @throws TorqueException Any exceptions caught during processing will be rethrown wrapped into a
   *     TorqueException.
   */
  protected static List<TOption> doSelectJoinTBLOB(Criteria criteria, Connection conn)
      throws TorqueException {
    setDbName(criteria);

    TOptionPeer.addSelectColumns(criteria);
    int offset = numColumns + 1;
    TBLOBPeer.addSelectColumns(criteria);

    criteria.addJoin(TOptionPeer.ICONKEY, TBLOBPeer.OBJECTID);

    correctBooleans(criteria);

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

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

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

      Class omClass = TOptionPeer.getOMClass();
      TOption obj1 = (TOption) TOptionPeer.row2Object(row, 1, omClass);
      omClass = TBLOBPeer.getOMClass();
      TBLOB obj2 = (TBLOB) TBLOBPeer.row2Object(row, offset, omClass);

      boolean newObject = true;
      for (int j = 0; j < results.size(); j++) {
        TOption temp_obj1 = results.get(j);
        TBLOB temp_obj2 = (TBLOB) temp_obj1.getTBLOB();
        if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) {
          newObject = false;
          temp_obj2.addTOption(obj1);
          break;
        }
      }
      if (newObject) {
        obj2.initTOptions();
        obj2.addTOption(obj1);
      }
      results.add(obj1);
    }
    return results;
  }
Exemplo n.º 3
0
  /**
   * Create a new object of type cls from a resultset row starting from a specified offset. This is
   * done so that you can select other rows than just those needed for this object. You may for
   * example want to create two objects from the same row.
   *
   * @throws TorqueException Any exceptions caught during processing will be rethrown wrapped into a
   *     TorqueException.
   */
  public static TOption row2Object(Record row, int offset, Class cls) throws TorqueException {
    try {
      TOption obj = (TOption) cls.newInstance();
      TOptionPeer.populateObject(row, offset, obj);
      obj.setModified(false);
      obj.setNew(false);

      return obj;
    } catch (InstantiationException e) {
      throw new TorqueException(e);
    } catch (IllegalAccessException e) {
      throw new TorqueException(e);
    }
  }
Exemplo n.º 4
0
 /**
  * Method to do deletes.
  *
  * @param criteria object containing data that is used DELETE from database.
  * @throws TorqueException Any exceptions caught during processing will be rethrown wrapped into a
  *     TorqueException.
  */
 public static void doDelete(Criteria criteria) throws TorqueException {
   TOptionPeer.doDelete(criteria, (Connection) null);
 }