コード例 #1
0
 private static void setDbName(Criteria crit) {
   // Set the correct dbName if it has not been overridden
   // crit.getDbName will return the same object if not set to
   // another value so == check is okay and faster
   if (crit.getDbName() == Torque.getDefaultDB()) {
     crit.setDbName(DATABASE_NAME);
   }
 }
コード例 #2
0
  /**
   * Method to do deletes. This method is to be used during a transaction, otherwise use the
   * doDelete(Criteria) method. It will take care of the connection details internally.
   *
   * @param criteria object containing data that is used DELETE from database.
   * @param con the connection to use
   * @throws TorqueException Any exceptions caught during processing will be rethrown wrapped into a
   *     TorqueException.
   */
  public static void doDelete(Criteria criteria, Connection con) throws TorqueException {

    // Set the correct dbName if it has not been overridden
    // criteria.getDbName will return the same object if not set to
    // another value so == check is okay and faster
    if (criteria.getDbName() == Torque.getDefaultDB()) {
      criteria.setDbName(DATABASE_NAME);
    }
    if (con == null) {
      BasePeer.doDelete(criteria);
    } else {
      BasePeer.doDelete(criteria, con);
    }
  }
コード例 #3
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;
  }
コード例 #4
0
  /**
   * Grabs the raw Village records to be formed into objects. This method should be used for
   * transactions
   *
   * @param con the connection to use
   * @throws TorqueException Any exceptions caught during processing will be rethrown wrapped into a
   *     TorqueException.
   */
  public static List doSelectVillageRecords(Criteria criteria, Connection con)
      throws TorqueException {
    if (criteria.getSelectColumns().size() == 0) {
      addSelectColumns(criteria);
    }

    // Set the correct dbName if it has not been overridden
    // criteria.getDbName will return the same object if not set to
    // another value so == check is okay and faster
    if (criteria.getDbName() == Torque.getDefaultDB()) {
      criteria.setDbName(DATABASE_NAME);
    }
    // BasePeer returns a List of Value (Village) arrays.  The array
    // order follows the order columns were placed in the Select clause.
    if (con == null) {
      return BasePeer.doSelect(criteria);
    } else {
      return BasePeer.doSelect(criteria, con);
    }
  }