@Override
  public Response loadData(
      int action,
      int startIndex,
      Map filteredColumns,
      ArrayList currentSortedColumns,
      ArrayList currentSortedVersusColumns,
      Class valueObjectType,
      Map otherGridParams) {
    Session s = null;
    try {

      String sql =
          "FROM "
              + claseModeloFullPath
              + " C WHERE C.personaPago.id=? "
              + "AND C.etapaSiniestro.idPropio=?";

      ArrayList<Object> al = new ArrayList<Object>(0);
      ArrayList<Type> ty = new ArrayList<Type>(0);
      al.add(personaPago.getId());
      ty.add(new LongType());
      al.add("LIQ");
      ty.add(new StringType());
      if (ordenDePago.getTipoDetalleSiniestro().equals(TipoDetalleSiniestro.Todos)) {
        sql += " AND C.tipoDetalle <> ? ";
        al.add(TipoDetalleSiniestro.Reembolso.toString());
        ty.add(new StringType());
      }
      SessionFactory sf = HibernateUtil.getSessionFactory();
      s = sf.openSession();
      Response res =
          HibernateUtils.getAllFromQuery(
              filteredColumns,
              currentSortedColumns,
              currentSortedVersusColumns,
              valueObjectType,
              sql,
              al.toArray(),
              ty.toArray(new Type[0]),
              "C",
              sf,
              s);
      return res;
    } catch (Exception ex) {
      LoggerUtil.error(this.getClass(), "loadData", ex);
      return new ErrorResponse(ex.getMessage());
    } finally {
      s.close();
    }
  }
コード例 #2
0
  @Override
  public Response loadData(
      int action,
      int startIndex,
      Map filteredColumns,
      ArrayList currentSortedColumns,
      ArrayList currentSortedVersusColumns,
      Class valueObjectType,
      Map otherGridParams) {
    Session s = null;
    try {
      String select =
          gridFrame
              .getGridControl()
              .getVOListTableModel()
              .createSelect("C", AliasedTupleSRT.SEPARATOR);
      select =
          select.replaceFirst("SELECT", "SELECT DISTINCT")
              + ", C.rif.tipoCedula as rif_tipoCedula ";

      String sql = select + " FROM " + claseModeloFullPath + " C LEFT JOIN C.tiposPersona T ";

      List<TipoPersona> tiposPersonasFiltradas =
          ((Personas2GridFrame) gridFrame).getTiposPersonaFiltro();
      if (tiposPersonasFiltradas != null && tiposPersonasFiltradas.size() != 0) {
        sql += "WHERE T.id IN ( ";
        sql += tiposPersonasFiltradas.get(0).getId();
        for (int i = 1; i < tiposPersonasFiltradas.size(); i++) {
          TipoPersona tipo = tiposPersonasFiltradas.get(i);
          sql += ", " + tipo.getId();
        }
        sql += " )";
      }
      this.sql1 = sql;
      this.filteredColumns = filteredColumns;
      SessionFactory sf = HibernateUtil.getSessionFactory();
      s = sf.openSession();
      Response res =
          HibernateUtils.getBlockFromQuery(
              new AliasedTupleSRT(Persona.class),
              action,
              startIndex,
              General.licencia.getBlockSize(),
              filteredColumns,
              currentSortedColumns,
              currentSortedVersusColumns,
              valueObjectType,
              sql,
              new Object[0],
              new Type[0],
              "C",
              sf,
              s);
      //            Response res = HibernateUtils.getAllFromQuery(
      //                    filteredColumns,
      //                    currentSortedColumns,
      //                    currentSortedVersusColumns,
      //                    valueObjectType,
      //                    sql,
      //                    new Object[0],
      //                    new Type[0],
      //                    "C",
      //                    sf,
      //                    s);
      return res;

      //            SessionFactory sf = HibernateUtil.getSessionFactory();
      //            Session s = sf.openSession();
      //            Criteria c = s.createCriteria(Persona.class);
      //            Criteria artistCriteria = c.createCriteria("tiposPersona");
      //            artistCriteria.add(Restrictions.like("idPropio", "%CON%"));
      //            Response res = HibernateUtils.getAllFromCriteria(filteredColumns,
      // currentSortedColumns, currentSortedVersusColumns, c, s);
      //            s.close();
      //            return res;
      //            SessionFactory sf = HibernateUtil.getSessionFactory();
      //            Session s = sf.openSession();
      //            Criteria c = s.createCriteria(Persona.class);
      //            Criteria artistCriteria = c.createCriteria("tiposPersona");
      //            artistCriteria.add(Expression.like("idPropio", "%CON%"));
      //            List l = c.list();
      //            s.close();
      //            return new VOListResponse(l, false, l.size());
    } catch (Exception ex) {
      LoggerUtil.error(this.getClass(), "loadData", ex);
      return new ErrorResponse(ex.getMessage());
    } finally {
      s.close();
    }
  }