/**
   * 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 System_Log row2Object(Record row, int offset, Class cls) throws TorqueException {
    try {
      System_Log obj = (System_Log) cls.newInstance();
      System_LogPeer.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);
    }
  }
 /** Build a Criteria object from the data object for this peer */
 public static Criteria buildCriteria(System_Log obj) {
   Criteria criteria = new Criteria(DATABASE_NAME);
   if (!obj.isNew()) criteria.add(LOG_ID, obj.getLog_ID());
   criteria.add(USER_ID, obj.getUser_ID());
   criteria.add(ACTION, obj.getAction());
   criteria.add(LOCATION, obj.getLocation());
   criteria.add(PREVIOUS_VALUE, obj.getPrevious_Value());
   criteria.add(CURRENT_VALUE, obj.getCurrent_Value());
   criteria.add(NOTES, obj.getNotes());
   criteria.add(DATE, obj.getDate());
   return criteria;
 }
  /**
   * 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;
  }
 /**
  * Populates an object 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 void populateObject(Record row, int offset, System_Log obj) throws TorqueException {
   try {
     obj.setLog_ID(row.getValue(offset + 0).asInt());
     obj.setUser_ID(row.getValue(offset + 1).asInt());
     obj.setAction(row.getValue(offset + 2).asString());
     obj.setLocation(row.getValue(offset + 3).asString());
     obj.setPrevious_Value(row.getValue(offset + 4).asInt());
     obj.setCurrent_Value(row.getValue(offset + 5).asInt());
     obj.setNotes(row.getValue(offset + 6).asString());
     obj.setDate(row.getValue(offset + 7).asString());
   } catch (DataSetException e) {
     throw new TorqueException(e);
   }
 }
 /**
  * Method to do update. This method is to be used during a transaction, otherwise use the
  * doUpdate(System_Log) method. It will take care of the connection details internally.
  *
  * @param obj the data object to update in the database.
  * @param con the connection to use
  * @throws TorqueException Any exceptions caught during processing will be rethrown wrapped into a
  *     TorqueException.
  */
 public static void doUpdate(System_Log obj, Connection con) throws TorqueException {
   doUpdate(buildCriteria(obj), con);
   obj.setModified(false);
 }
 /**
  * Method to do inserts. This method is to be used during a transaction, otherwise use the
  * doInsert(System_Log) method. It will take care of the connection details internally.
  *
  * @param obj the data object to insert into the database.
  * @param con the connection to use
  * @throws TorqueException Any exceptions caught during processing will be rethrown wrapped into a
  *     TorqueException.
  */
 public static void doInsert(System_Log obj, Connection con) throws TorqueException {
   obj.setPrimaryKey(doInsert(buildCriteria(obj), con));
   obj.setNew(false);
   obj.setModified(false);
 }