Esempio n. 1
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 ProductCategory row2Object(Record row, int offset, Class cls)
      throws TorqueException {
    try {
      ProductCategory obj = (ProductCategory) cls.newInstance();
      ProductCategoryPeer.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);
    }
  }
Esempio n. 2
0
  /**
   * Class object initialization method.
   *
   * @param className name of the class to initialize
   * @return the initialized class
   */
  private static Class initClass(String className) {
    Class c = null;
    try {
      c = Class.forName(className);
    } catch (Throwable t) {
      log.error(
          "A FATAL ERROR has occurred which should not "
              + "have happened under any circumstance.  Please notify "
              + "the Torque developers <*****@*****.**> "
              + "and give as many details as possible (including the error "
              + "stack trace).",
          t);

      // Error objects should always be propogated.
      if (t instanceof Error) {
        throw (Error) t.fillInStackTrace();
      }
    }
    return c;
  }