/**
   * selects a collection of OrdenTrabajo objects pre-filled with their Reparacion 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 doSelectJoinReparacion(Criteria criteria) throws TorqueException {
    setDbName(criteria);

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

    criteria.addJoin(OrdenTrabajoPeer.REPARACION_ID, ReparacionPeer.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 = ReparacionPeer.getOMClass();
      Reparacion obj2 = (Reparacion) ReparacionPeer.row2Object(row, offset, omClass);

      boolean newObject = true;
      for (int j = 0; j < results.size(); j++) {
        OrdenTrabajo temp_obj1 = (OrdenTrabajo) results.get(j);
        Reparacion temp_obj2 = (Reparacion) temp_obj1.getReparacion();
        if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) {
          newObject = false;
          break;
        }
      }
      results.add(obj1);
    }
    return results;
  }
Beispiel #2
0
  /**
   * Get the associated Reparacion object
   *
   * @return the associated Reparacion object
   * @throws TorqueException
   */
  public Reparacion getReparacion() throws TorqueException {
    if (aReparacion == null && (this.reparacionId != 0)) {
      aReparacion = ReparacionPeer.retrieveByPK(SimpleKey.keyFor(this.reparacionId));

      /* The following can be used instead of the line above to
         guarantee the related object contains a reference
         to this object, but this level of coupling
         may be undesirable in many circumstances.
         As it can lead to a db query with many results that may
         never be used.
         Reparacion obj = ReparacionPeer.retrieveByPK(this.reparacionId);
         obj.addPrestamos(this);
      */
    }
    return aReparacion;
  }