Esempio n. 1
0
 /** Build a Criteria object from the data object for this peer */
 public static Criteria buildCriteria(TRoleListType obj) {
   Criteria criteria = new Criteria(DATABASE_NAME);
   if (!obj.isNew()) criteria.add(OBJECTID, obj.getObjectID());
   criteria.add(PROLE, obj.getRole());
   criteria.add(LISTTYPE, obj.getListType());
   criteria.add(TPUUID, obj.getUuid());
   return criteria;
 }
Esempio n. 2
0
 /**
  * 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, TRoleListType obj)
     throws TorqueException {
   try {
     obj.setObjectID(row.getValue(offset + 0).asIntegerObj());
     obj.setRole(row.getValue(offset + 1).asIntegerObj());
     obj.setListType(row.getValue(offset + 2).asIntegerObj());
     obj.setUuid(row.getValue(offset + 3).asString());
   } catch (DataSetException e) {
     throw new TorqueException(e);
   }
 }
Esempio 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 TRoleListType row2Object(Record row, int offset, Class cls) throws TorqueException {
    try {
      TRoleListType obj = (TRoleListType) cls.newInstance();
      TRoleListTypePeer.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. 4
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;
  }
Esempio n. 5
0
 /**
  * Method to do update. This method is to be used during a transaction, otherwise use the
  * doUpdate(TRoleListType) 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(TRoleListType obj, Connection con) throws TorqueException {
   doUpdate(buildCriteria(obj), con);
   obj.setModified(false);
 }
Esempio n. 6
0
 /**
  * Method to do inserts. This method is to be used during a transaction, otherwise use the
  * doInsert(TRoleListType) 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(TRoleListType obj, Connection con) throws TorqueException {
   obj.setPrimaryKey(doInsert(buildCriteria(obj), con));
   obj.setNew(false);
   obj.setModified(false);
 }