/**
   * Method to do inserts. This method is to be used during a transaction, otherwise use the
   * doInsert(Criteria) method. It will take care of the connection details internally.
   *
   * @param criteria object used to create the INSERT statement.
   * @param con the connection to use
   * @throws TorqueException Any exceptions caught during processing will be rethrown wrapped into a
   *     TorqueException.
   */
  public static ObjectKey doInsert(Criteria criteria, Connection con) throws TorqueException {

    setDbName(criteria);

    if (con == null) {
      return BasePeer.doInsert(criteria);
    } else {
      return BasePeer.doInsert(criteria, con);
    }
  }
  /**
   * 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 {

    setDbName(criteria);

    if (con == null) {
      BasePeer.doDelete(criteria);
    } else {
      BasePeer.doDelete(criteria, con);
    }
  }
Пример #3
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 {
    correctBooleans(criteria);

    setDbName(criteria);

    if (con == null) {
      BasePeer.doDelete(criteria, TABLE_NAME);
    } else {
      BasePeer.doDelete(criteria, TABLE_NAME, con);
    }
  }
  /**
   * Method to do updates. This method is to be used during a transaction, otherwise use the
   * doUpdate(Criteria) method. It will take care of the connection details internally.
   *
   * @param criteria object containing data that is used to create the UPDATE statement.
   * @param con the connection to use
   * @throws TorqueException Any exceptions caught during processing will be rethrown wrapped into a
   *     TorqueException.
   */
  public static void doUpdate(Criteria criteria, Connection con) throws TorqueException {
    Criteria selectCriteria = new Criteria(DATABASE_NAME, 2);
    selectCriteria.put(ID, criteria.remove(ID));

    setDbName(criteria);

    if (con == null) {
      BasePeer.doUpdate(selectCriteria, criteria);
    } else {
      BasePeer.doUpdate(selectCriteria, criteria, con);
    }
  }
Пример #5
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);
    }
  }
  /**
   * Grabs the raw Village records to be formed into objects. This method should be used for
   * transactions
   *
   * @param criteria object used to create the SELECT statement.
   * @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);
    }

    setDbName(criteria);

    // 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);
    }
  }
  /**
   * selects a collection of OrdenTrabajo objects pre-filled with their Trabajador 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 OrdenTrabajoPeer.
   *
   * @throws TorqueException Any exceptions caught during processing will be rethrown wrapped into a
   *     TorqueException.
   */
  protected static List doSelectJoinTrabajador(Criteria criteria) throws TorqueException {
    setDbName(criteria);

    OrdenTrabajoPeer.addSelectColumns(criteria);
    int offset = numColumns + 1;
    TrabajadorPeer.addSelectColumns(criteria);

    criteria.addJoin(OrdenTrabajoPeer.RESPONSABLE_ID, TrabajadorPeer.ID);

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

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

      Class omClass = OrdenTrabajoPeer.getOMClass();
      OrdenTrabajo obj1 = (OrdenTrabajo) OrdenTrabajoPeer.row2Object(row, 1, omClass);
      omClass = TrabajadorPeer.getOMClass();
      Trabajador obj2 = (Trabajador) TrabajadorPeer.row2Object(row, offset, omClass);

      boolean newObject = true;
      for (int j = 0; j < results.size(); j++) {
        OrdenTrabajo temp_obj1 = (OrdenTrabajo) results.get(j);
        Trabajador temp_obj2 = (Trabajador) temp_obj1.getTrabajador();
        if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) {
          newObject = false;
          break;
        }
      }
      results.add(obj1);
    }
    return results;
  }
Пример #8
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;
  }
Пример #9
0
  /**
   * selects a collection of TRoleListType objects pre-filled with their TListType 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> doSelectJoinTListType(Criteria criteria, Connection conn)
      throws TorqueException {
    setDbName(criteria);

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

    criteria.addJoin(TRoleListTypePeer.LISTTYPE, TListTypePeer.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 = TListTypePeer.getOMClass();
      TListType obj2 = (TListType) TListTypePeer.row2Object(row, offset, omClass);

      boolean newObject = true;
      for (int j = 0; j < results.size(); j++) {
        TRoleListType temp_obj1 = results.get(j);
        TListType temp_obj2 = (TListType) temp_obj1.getTListType();
        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;
  }
Пример #10
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);
    }
  }
  /**
   * 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;
  }
Пример #12
0
 /**
  * Method for performing a SELECT. Returns all results.
  *
  * @param queryString A String with the sql statement to execute.
  * @param start The first row to return.
  * @param numberOfResults The number of rows to return.
  * @param singleRecord Whether or not we want to select only a single record.
  * @param con A Connection.
  * @return List of Record objects.
  * @throws TorqueException Any exceptions caught during processing will be rethrown wrapped into a
  *     TorqueException.
  * @see org.apache.torque.util.BasePeer#executeQuery(String,int,int,String,boolean,Connection)
  */
 public static List<Record> executeQuery(
     String queryString, int start, int numberOfResults, boolean singleRecord, Connection con)
     throws TorqueException {
   return BasePeer.executeQuery(queryString, start, numberOfResults, singleRecord, con);
 }
Пример #13
0
 /**
  * Utility method which executes a given sql statement. This method should be used for select
  * statements only. Use executeStatement for update, insert, and delete operations.
  *
  * @param queryString A String with the sql statement to execute.
  * @return List of Record objects.
  * @throws TorqueException Any exceptions caught during processing will be rethrown wrapped into a
  *     TorqueException.
  * @see org.apache.torque.util.BasePeer#executeQuery(String)
  */
 public static List<Record> executeQuery(String queryString) throws TorqueException {
   return BasePeer.executeQuery(queryString);
 }
Пример #14
0
 /**
  * Do a Prepared Statement select according to the given criteria
  *
  * @param criteria
  * @return a List of Record objects.
  * @throws TorqueException Any exceptions caught during processing will be rethrown wrapped into a
  *     TorqueException.
  * @see org.apache.torque.util.BasePeer#doPSSelect(Criteria)
  */
 public static List<Record> doPSSelect(Criteria criteria) throws TorqueException {
   return BasePeer.doPSSelect(criteria);
 }
Пример #15
0
 /**
  * Method for performing a SELECT. Returns all results.
  *
  * @param queryString A String with the sql statement to execute.
  * @param dbName The database to connect to.
  * @param singleRecord Whether or not we want to select only a single record.
  * @return List of Record objects.
  * @throws TorqueException Any exceptions caught during processing will be rethrown wrapped into a
  *     TorqueException.
  * @see org.apache.torque.util.BasePeer#executeQuery(String,String,boolean)
  */
 public static List<Record> executeQuery(String queryString, String dbName, boolean singleRecord)
     throws TorqueException {
   return BasePeer.executeQuery(queryString, dbName, singleRecord);
 }
Пример #16
0
 /**
  * Method for performing a SELECT. Returns all results.
  *
  * @param queryString A String with the sql statement to execute.
  * @param singleRecord Whether or not we want to select only a single record.
  * @param con A Connection.
  * @return List of Record objects.
  * @throws TorqueException Any exceptions caught during processing will be rethrown wrapped into a
  *     TorqueException.
  * @see org.apache.torque.util.BasePeer#executeQuery(String,boolean,Connection)
  */
 public static List<Record> executeQuery(String queryString, boolean singleRecord, Connection con)
     throws TorqueException {
   return BasePeer.executeQuery(queryString, singleRecord, con);
 }
Пример #17
0
 /**
  * Method for performing a SELECT.
  *
  * @param queryString A String with the sql statement to execute.
  * @param start The first row to return.
  * @param numberOfResults The number of rows to return.
  * @param dbName The database to connect to.
  * @param singleRecord Whether or not we want to select only a single record.
  * @return List of Record objects.
  * @throws TorqueException Any exceptions caught during processing will be rethrown wrapped into a
  *     TorqueException.
  * @see org.apache.torque.util.BasePeer#executeQuery(String,int,int,String,boolean)
  */
 public static List<Record> executeQuery(
     String queryString, int start, int numberOfResults, String dbName, boolean singleRecord)
     throws TorqueException {
   return BasePeer.executeQuery(queryString, start, numberOfResults, dbName, singleRecord);
 }
Пример #18
0
 /**
  * Returns all records in a QueryDataSet as a List of Record objects. Used for functionality like
  * util.LargeSelect.
  *
  * @see #getSelectResults(QueryDataSet, int, int, boolean)
  * @param qds the QueryDataSet
  * @return a List of Record objects
  * @throws TorqueException Any exceptions caught during processing will be rethrown wrapped into a
  *     TorqueException.
  * @see org.apache.torque.util.BasePeer#getSelectResults(QueryDataSet)
  */
 public static List<Record> getSelectResults(QueryDataSet qds) throws TorqueException {
   return BasePeer.getSelectResults(qds);
 }
Пример #19
0
 /**
  * Returns numberOfResults records in a QueryDataSet as a List of Record objects. Starting at
  * record 0. Used for functionality like util.LargeSelect.
  *
  * @see #getSelectResults(QueryDataSet, int, int, boolean)
  * @param qds the QueryDataSet
  * @param numberOfResults
  * @param singleRecord
  * @return a List of Record objects
  * @throws TorqueException Any exceptions caught during processing will be rethrown wrapped into a
  *     TorqueException.
  * @see org.apache.torque.util.BasePeer#getSelectResults(QueryDataSet,int,boolean)
  */
 public static List<Record> getSelectResults(
     QueryDataSet qds, int numberOfResults, boolean singleRecord) throws TorqueException {
   return BasePeer.getSelectResults(qds, numberOfResults, singleRecord);
 }