private DetachedCriteria subquery(SubqueryExpression sqex) {

    String entityName = sqex.getTargetPropertyName();
    String alias = Texts.tos(sqex.getAlias(), null);

    DetachedCriteria dtc;
    if (alias != null) {
      dtc = DetachedCriteria.forEntityName(entityName, alias);
    } else {
      dtc = DetachedCriteria.forEntityName(entityName);
    }
    if (log.isTraceEnabled()) {
      log.trace(
          String.format(
              "Creating detached criteria for entity %s of type %s as %s",
              entityName, sqex.getType(), sqex.getValue()));
    }

    if (sqex.getValue() instanceof Restrictions) {
      Restrictions restr = (Restrictions) sqex.getValue();
      dtc.setProjection(Projections.id());
      dtc.add(parseRestriction(restr));
    } else if (sqex.getValue() instanceof Where) {
      dtc.setProjection(Projections.id());
      DetachedWhereParser whp = new DetachedWhereParser();
      whp.parse((Where) sqex.getValue(), dtc);
    } else {
      throw new IllegalStateException(
          String.format(
              "Subquery must be instance of restrictions or Where, but is %s",
              sqex.getValue().getClass().getName()));
    }

    return dtc;
  }
Ejemplo n.º 2
0
 /**
  * 使用检索标准对象查询记录数
  *
  * @param detachedCriteria
  * @return
  */
 public long count(DetachedCriteria detachedCriteria) {
   long count =
       ((Number)
               detachedCriteria
                   .setProjection(Projections.rowCount())
                   .getExecutableCriteria(getSession())
                   .uniqueResult())
           .longValue();
   detachedCriteria.setProjection(null);
   return count;
 }
Ejemplo n.º 3
0
  private List<HashMap<String, Object>> getQuestionAnswerData(ExamResult examResult) {
    DetachedCriteria criteria =
        DetachedCriteria.forClass(ExamResultAnswer.class, "examResultAnswer");
    criteria.createAlias("examResultAnswer.question", "question");
    criteria.createAlias("examResultAnswer.answer1", "answer1");
    criteria.createAlias("examResultAnswer.answer2", "answer2");
    criteria.createAlias("examResultAnswer.answer3", "answer3");
    criteria.createAlias("examResultAnswer.answer4", "answer4");

    ProjectionList projectionList = Projections.projectionList();
    projectionList.add(Projections.property("question.questionId"), "questionId");
    projectionList.add(Projections.property("question.questionText"), "questionText");
    projectionList.add(Projections.property("answer1.answerId"), "answer1Id");
    projectionList.add(Projections.property("answer1.answerText"), "answer1Text");
    projectionList.add(Projections.property("answer2.answerId"), "answer2Id");
    projectionList.add(Projections.property("answer2.answerText"), "answer2Text");
    projectionList.add(Projections.property("answer3.answerId"), "answer3Id");
    projectionList.add(Projections.property("answer3.answerText"), "answer3Text");
    projectionList.add(Projections.property("answer4.answerId"), "answer4Id");
    projectionList.add(Projections.property("answer4.answerText"), "answer4Text");
    projectionList.add(
        Projections.property("examResultAnswer.examResultAnswerId"), "examResultAnswerId");
    projectionList.add(Projections.property("examResultAnswer.answerId"), "answerId");
    criteria.setProjection(projectionList);
    criteria.add(Restrictions.eq("examResultAnswer.examResultId", examResult.getExamResultId()));
    criteria.addOrder(Order.asc("examResultAnswer.ordinal"));
    criteria.setResultTransformer(Criteria.ALIAS_TO_ENTITY_MAP);

    return basicFinderService.findByCriteria(criteria);
  }
Ejemplo n.º 4
0
  @Override
  public List<ThesaurusConcept> getPaginatedAvailableConceptsOfGroup(
      Integer startIndex,
      Integer limit,
      String groupId,
      String thesaurusId,
      Boolean onlyValidatedConcepts,
      String like) {

    DetachedCriteria dc = DetachedCriteria.forClass(ThesaurusConceptGroup.class, "gr");
    dc.createCriteria("concepts", "tc", JoinType.RIGHT_OUTER_JOIN);
    dc.setProjection(Projections.projectionList().add(Projections.property("tc.identifier")));
    dc.add(Restrictions.eq("gr.identifier", groupId));

    Criteria criteria = selectPaginatedConceptsByAlphabeticalOrder(startIndex, limit);
    criteria.add(Subqueries.propertyNotIn("tc.identifier", dc));

    selectThesaurus(criteria, thesaurusId);
    criteria.add(
        Restrictions.not(
            Restrictions.and(
                Restrictions.eq("topConcept", false),
                Restrictions.or(
                    Restrictions.isNull("tc.parentConcepts"),
                    Restrictions.isEmpty("tc.parentConcepts")))));

    if (null != like) {
      conceptNameIsLike(criteria, like);
    }
    onlyValidatedConcepts(criteria, onlyValidatedConcepts);

    return criteria.list();
  }
  private static void populateHibernateDetachedCriteria(
      AbstractHibernateQuery hibernateQuery,
      org.hibernate.criterion.DetachedCriteria detachedCriteria,
      QueryableCriteria<?> queryableCriteria) {
    List<Query.Criterion> criteriaList = queryableCriteria.getCriteria();
    for (Query.Criterion criterion : criteriaList) {
      Criterion hibernateCriterion =
          HibernateQuery.HIBERNATE_CRITERION_ADAPTER.toHibernateCriterion(
              hibernateQuery, criterion, null);
      if (hibernateCriterion != null) {
        detachedCriteria.add(hibernateCriterion);
      }
    }

    List<Query.Projection> projections = queryableCriteria.getProjections();
    ProjectionList projectionList = Projections.projectionList();
    for (Query.Projection projection : projections) {
      Projection hibernateProjection =
          new HibernateProjectionAdapter(projection).toHibernateProjection();
      if (hibernateProjection != null) {
        projectionList.add(hibernateProjection);
      }
    }
    detachedCriteria.setProjection(projectionList);
  }
  public void prepareDateRange() throws Exception {
    DetachedCriteria criteria = DetachedCriteria.forClass(ConfirmationRecord.class);
    ProjectionList pjl = Projections.projectionList();
    pjl.add(Projections.property("cycleFrom"));
    pjl.add(Projections.property("cycleTo"));
    criteria.setProjection(Projections.distinct(pjl));

    List<?> list = confirmationRecordService.findByCriteria(criteria);
    if (list.size() > 0) {
      Object[] objs = list.toArray();
      selectionCycleFrom = new ArrayList<>();
      selectionCycleFrom.add(new SelectItem(null, "Please Select"));
      cycleTos = new ArrayList<>();

      for (Object obj : objs) {
        if (obj instanceof Object[]) {
          Object[] innerObjs = (Object[]) obj;
          if (innerObjs.length == 2) {
            Date dFrom = DateUtil.convStringToDate(MS_SQL_DATE_PATTERN, innerObjs[0].toString());
            Date dTo = DateUtil.convStringToDate(MS_SQL_DATE_PATTERN, innerObjs[1].toString());
            selectionCycleFrom.add(
                new SelectItem(
                    DateUtil.convDateToString(SIMPLE_DATE_PATTERN, dFrom),
                    DateUtil.convDateToString(DISPLAY_DATE_PATTERN, dFrom)));
            cycleTos.add(DateUtil.convDateToString(SIMPLE_DATE_PATTERN, dTo));
          } else {
            System.err.println("ERR: obj[] length not eq to 2");
          }
        }
      }
    }
  }
Ejemplo n.º 7
0
  @Override
  public int getFormsCount(Person owner) {
    DetachedCriteria criteria = DetachedCriteria.forClass(type);
    criteria.setProjection(Projections.distinct(Projections.countDistinct("formName")));
    if (owner != null) criteria.add(Restrictions.eq("person.personId", owner.getPersonId()));

    return DataAccessUtils.intResult(getHibernateTemplate().findByCriteria(criteria));
  }
 public List<String> getSharedListUserNames() {
   DetachedCriteria criteria = DetachedCriteria.forClass(CustomSeriesList.class);
   ProjectionList projectionList = Projections.projectionList();
   projectionList.add(Projections.property("userName"));
   criteria.setProjection(Projections.distinct(projectionList));
   List<String> results = new ArrayList<String>();
   results = getHibernateTemplate().findByCriteria(criteria);
   return results;
 }
Ejemplo n.º 9
0
 public List<?> getLoginList() { // 获得管理员和密码的列表
   DetachedCriteria criteria = DetachedCriteria.forClass(Admin.class);
   criteria.setProjection(
       (Projections.projectionList()
           .add(Projections.property("name"))
           .add(Projections.property("password"))));
   List<?> list = getHibernateTemplate().findByCriteria(criteria);
   return list;
 }
Ejemplo n.º 10
0
  @Override
  @SuppressWarnings("unchecked")
  public List<String> getFormNames(Person owner) {
    DetachedCriteria criteria = DetachedCriteria.forClass(type);
    criteria.setProjection(Projections.distinct(Projections.property("formName")));
    if (owner != null) criteria.add(Restrictions.eq("person.personId", owner.getPersonId()));

    return getHibernateTemplate().findByCriteria(criteria);
  }
Ejemplo n.º 11
0
  @Override
  public int getLayoutsCount(Person owner, String formName, FormLayoutType templateType) {
    DetachedCriteria criteria = DetachedCriteria.forClass(type);
    criteria.setProjection(Projections.rowCount());
    if (owner != null) criteria.add(Restrictions.eq("person.personId", owner.getPersonId()));
    if (formName != null) criteria.add(Restrictions.eq("formName", formName));
    if (templateType != null) criteria.add(Restrictions.eq("type", templateType));

    return DataAccessUtils.intResult(getHibernateTemplate().findByCriteria(criteria));
  }
  public String execute() {
    int to = rows * page;
    int from = to - rows;
    DetachedCriteria criteria = DetachedCriteria.forClass(Cliente.class);

    // Si el campo de busqueda es diferente de nulo
    if (searchField != null) {
      if (searchField.equals("idcliente")) {
        if (searchOper.equals("eq")) {
          BigDecimal searchValue = new BigDecimal(searchString);
          criteria.add(Restrictions.eq("idcliente", searchValue));
        } else if (searchOper.equals("lt")) {
          BigDecimal searchValue = new BigDecimal(searchString);
          criteria.add(Restrictions.lt("idcliente", searchValue));

        } else if (searchOper.equals("gt")) {
          BigDecimal searchValue = new BigDecimal(searchString);
          criteria.add(Restrictions.gt("idcliente", searchValue));
        }
      } else if (searchField.equals("nombre")) {
        // contains
        if (searchOper.equals("cn")) {
          criteria.add(Restrictions.like("nombre", "%" + searchString + "%"));
        }
      } else if (searchField.equals("banco.nombre")) {
        criteria.createAlias("banco", "b");
        if (searchOper.equals("eq")) {
          criteria.add(Restrictions.eq("b.nombre", searchString));
        }
      }
    }

    // Count Customers
    records = clienteService.countByCriteria(criteria);

    // Reset count Projection
    criteria.setProjection(null);
    criteria.setResultTransformer(Criteria.ROOT_ENTITY);

    if (sidx != null && !sidx.equals("")) {
      if (sord.equals("asc")) {
        criteria.addOrder(Order.asc(sidx));
      } else {
        criteria.addOrder(Order.desc(sidx));
      }
    }

    gridModel = clienteService.findByCriteria(criteria, from, rows);

    if (to > records) to = records;

    total = (int) Math.ceil((double) records / (double) rows);

    return "success";
  }
  @SuppressWarnings("unchecked")
  @Override
  public List<Oficina> listarOficinas(Integer idInscricaoCurso) {
    Criteria criteria = getSession().createCriteria(Oficina.class);
    DetachedCriteria subCriteria = DetachedCriteria.forClass(SelecaoOficina.class);
    subCriteria.add(Property.forName("inscricaoCurso.id").eq(idInscricaoCurso));
    subCriteria.setProjection(Projections.distinct(Projections.property("oficina.id")));

    criteria.add(Property.forName("id").in(subCriteria));
    return criteria.list();
  }
Ejemplo n.º 14
0
  /**
   * 分页公共方法(非easyui)
   *
   * @author Alexander
   * @date 20131022
   */
  public List<?> pageBaseMethod(
      HttpServletRequest request, DetachedCriteria dc, CommonService commonService, int pageRow) {
    // 当前页
    // 总条数
    // 总页数

    int currentPage = 1;

    int totalRow = 0;
    int totalPage = 0;
    // 获取当前页
    String str_currentPage = request.getParameter("str_currentPage");
    currentPage =
        str_currentPage == null || "".equals(str_currentPage)
            ? 1
            : Integer.parseInt(str_currentPage);
    // 获取每页的条数
    String str_pageRow = request.getParameter("str_pageRow");
    pageRow =
        str_pageRow == null || "".equals(str_pageRow) ? pageRow : Integer.parseInt(str_pageRow);

    // 统计的总行数
    dc.setProjection(Projections.rowCount());

    totalRow = Integer.parseInt(commonService.findByDetached(dc).get(0).toString());
    totalPage = (totalRow + pageRow - 1) / pageRow;

    currentPage = currentPage < 1 ? 1 : currentPage;
    currentPage = currentPage > totalPage ? totalPage : currentPage;
    // 清空统计函数
    dc.setProjection(null);
    dc.setResultTransformer(dc.DISTINCT_ROOT_ENTITY);
    List<?> list = commonService.pageList(dc, (currentPage - 1) * pageRow, pageRow);

    request.setAttribute("currentPage", currentPage);
    request.setAttribute("pageRow", pageRow);
    request.setAttribute("totalRow", totalRow);
    request.setAttribute("totalPage", totalPage);
    return list;
  }
Ejemplo n.º 15
0
  @Override
  public Integer getNumberOfDeals(User userToGetDeals) {
    DetachedCriteria criteria =
        DetachedCriteria.forClass(Deal.class)
            .createAlias("customer", "customer", CriteriaSpecification.LEFT_JOIN);

    if (userToGetDeals != null) {
      criteria.add(Restrictions.eq("user", userToGetDeals));
    }

    criteria.setProjection(Projections.rowCount());
    return (Integer) hibernateTemplate.findByCriteria(criteria).get(0);
  }
Ejemplo n.º 16
0
  /**
   * 修改初始化方法 也是根据iD查询实体的方法 在action加能过注解把这个实体to json
   *
   * @param: res
   */
  @SuppressWarnings("unchecked")
  public void findById(BusinessRequest res) {

    HopIncDto dto = super.getDto(HopIncDto.class, res);

    // 调用对应的service方法

    hopIncService.findById(dto);
    DetachedCriteria criteria = DetachedCriteria.forClass(HopIncAlias.class);
    criteria.setProjection(Property.forName("incAliasText"));
    criteria.add(Restrictions.eq("incAliaIncId", dto.getHopInc().getIncId()));
    List<String> alias = commonService.findByDetachedCriteria(criteria);
    dto.getHopInc().setIncAliaS(org.apache.commons.lang.StringUtils.join(alias, ","));
  }
  @SuppressWarnings("unchecked")
  @Override
  public List<Oficina> recuperarOficina(Integer idCurso, Integer idPacote) {
    Criteria criteria = getSession().createCriteria(Oficina.class);

    DetachedCriteria subCriteria = DetachedCriteria.forClass(PacoteOficina.class);
    subCriteria.createAlias("pacote", "p");
    subCriteria.add(Property.forName("p.id").eq(idPacote));
    subCriteria.createAlias("p.curso", "c");
    subCriteria.add(Property.forName("c.id").eq(idCurso));
    subCriteria.setProjection(Projections.distinct(Projections.property("oficina.id")));

    criteria.add(Property.forName("id").in(subCriteria));
    return criteria.list();
  }
Ejemplo n.º 18
0
  public PaginatedList<Keyword> findKeywords(
      Keyword keyword,
      final boolean ignoreCase,
      final Order order,
      final Integer firstResult,
      final Integer maxResults)
      throws IllegalArgumentException {
    if (keyword == null) {
      throw new IllegalArgumentException("keyword cannot be null");
    }
    final MatchMode matchMode = MatchMode.ANYWHERE;
    Example criterionKeyword = Example.create(keyword);
    criterionKeyword.enableLike(matchMode);
    if (ignoreCase) {
      criterionKeyword.ignoreCase();
    }

    // Normally, Hibernate performs a left-outer join, when searching for
    // an object with collections using Criteria. This returns a ResultSet
    // that contains duplicate objects. In order to get a unique list of
    // Keywords with paginated support, we need to a nested query to find
    // distinct matching ids, then get the Keywords. The end result is a
    // subselect in the main query, but only one query is sent.
    DetachedCriteria dc = DetachedCriteria.forClass(Keyword.class);
    dc.add(criterionKeyword);
    dc.setResultTransformer(DISTINCT_ROOT_ENTITY);

    Conjunction conjunction =
        createTranslationConditions(keyword.getTranslations(), ignoreCase, matchMode);
    if (conjunction != null) dc.createCriteria(FIELD_TRANSLATIONS).add(conjunction);
    dc.setProjection(Projections.id());

    Criteria criteria = getSession().createCriteria(Keyword.class);
    criteria.add(Subqueries.propertyIn(FIELD_ID, dc));
    if (Order.desc == order) criteria.addOrder(desc(FIELD_KEYWORD));
    else criteria.addOrder(asc(FIELD_KEYWORD));
    if (firstResult != null) criteria.setFirstResult(firstResult);
    if (maxResults != null) criteria.setMaxResults(maxResults);

    final List<Keyword> criteriaList = criteria.list();
    int maxListSize = 0;
    if (criteriaList.size() > 0) {
      maxListSize = calculateMaxListSize(criterionKeyword, conjunction);
    }

    return new PaginatedList<Keyword>(criteriaList, maxListSize);
  }
  public Collection<String> findAllQuantificationNames() throws DataAccessException {

    DetachedCriteria criteria = DetachedCriteria.forClass(AimQuantification.class, "q");

    ProjectionList projectionList = Projections.projectionList();
    projectionList.add(Projections.property("name"));

    criteria.setProjection(Projections.distinct(projectionList));

    Collection<String> names = new ArrayList<String>();

    Collection<String> results = getHibernateTemplate().findByCriteria(criteria);
    for (String result : results) {
      names.add(result);
    }
    return names;
  }
Ejemplo n.º 20
0
 /**
  * Get social accounts stats.
  *
  * @param socialAccount {@link SocialAccount}.
  * @return
  */
 @SuppressWarnings("unchecked")
 public HashMap<String, Long> getSocialAccountStats(final SocialAccount socialAccount) {
   final HashMap<String, Long> stats = new HashMap<String, Long>();
   log.debug("getSocialAccountStats " + socialAccount.getId());
   final DetachedCriteria criteria =
       DetachedCriteria.forClass(TweetPollSavedPublishedStatus.class);
   criteria.add(Restrictions.eq("socialAccount", socialAccount));
   criteria.setProjection(Projections.rowCount());
   final List tweetPollstats = getHibernateTemplate().findByCriteria(criteria);
   log.debug("getSocialAccountStats " + tweetPollstats.size());
   log.debug("getSocialAccountStats " + tweetPollstats);
   if (tweetPollstats.size() > 0) {
     stats.put("tweetpoll", Long.valueOf(tweetPollstats.get(0).toString()));
   } else {
     stats.put("tweetpoll", 0L);
   }
   // TODO: in the future we can add another stats.
   stats.put("poll", 0L);
   stats.put("survey", 0L);
   log.debug("getSocialAccountStats stats" + stats);
   return stats;
 }
  private List<Object[]> getSharedListResult(List<String> seriesUids) {
    List<Object[]> results = new ArrayList<Object[]>();

    if (seriesUids != null && seriesUids.size() != 0) {
      DetachedCriteria criteria = DetachedCriteria.forClass(CustomSeriesListAttribute.class);
      ProjectionList projectionList = Projections.projectionList();

      projectionList.add(Projections.property("csl.userName"));
      projectionList.add(Projections.property("csl.name"));
      projectionList.add(Projections.property("seriesInstanceUid"));

      criteria.setProjection(Projections.distinct(projectionList));

      criteria.createAlias("parent", "csl");

      criteria.add(Restrictions.in("seriesInstanceUid", seriesUids));

      results = getHibernateTemplate().findByCriteria(criteria);
    }

    return results;
  }
Ejemplo n.º 22
0
  public List<DmFolder> getSharedFirstLevelList(String accountSharedId, String accountOwnerId) {
    DmAccount permittedAccount = null;
    if (accountSharedId != null) {
      permittedAccount = new DmAccount();
      permittedAccount.setId(accountSharedId);
    }

    DmAccount ownerAccount = null;
    if (accountOwnerId != null) {
      ownerAccount = new DmAccount();
      ownerAccount.setId(accountOwnerId);
    }

    List<DmFolder> folderList = null;
    if (permittedAccount != null) {
      Criteria crit = getSession().createCriteria(DmFolderPermission.class);
      crit.setProjection(Projections.property("folder"));

      Conjunction conjunction = Restrictions.conjunction();
      //            conjunction.add(Restrictions.ge("permissionType",
      // ApplicationConstants.FOLDER_PERMISSION_MANAGER));
      conjunction.add(Restrictions.eq("account", permittedAccount));
      conjunction.add(Restrictions.ne("account", ownerAccount));
      crit.add(conjunction);

      crit.createAlias("folder", "folderShared", CriteriaSpecification.LEFT_JOIN);
      crit.add(Restrictions.eq("folderShared.owner", ownerAccount));

      crit.createAlias("folderShared.parent", "parentFolder", CriteriaSpecification.LEFT_JOIN);
      //            crit.createAlias("parentFolder.permissionList", "parentPermission");
      crit.createAlias(
          "parentFolder.permissionList", "parentPermission", CriteriaSpecification.LEFT_JOIN);

      //            DetachedCriteria subquery = DetachedCriteria.forClass(DmFolder.class,
      // "last_pos");
      DetachedCriteria subquery = DetachedCriteria.forClass(DmFolderPermission.class);
      subquery.setProjection(Projections.property("folder"));
      subquery.add(conjunction);

      Disjunction disjunction = Restrictions.disjunction();
      disjunction.add(Restrictions.isNull("folderShared.parent"));
      //            disjunction.add(Restrictions.isNull("parentFolder.permissionList"));
      //            disjunction.add(Restrictions.isNull("parentPermission.id"));
      //            disjunction.add(conjunction2);
      disjunction.add(Subqueries.propertyNotIn("folderShared.parent", subquery));

      //            crit.add(Subqueries.propertyNotIn("folderShared.parent", subquery));

      //            Conjunction conjunction2 = Restrictions.conjunction();
      //            conjunction2.add(Restrictions.eq("parentPermission.permissionType",
      // ApplicationConstants.FOLDER_PERMISSION_MANAGER));
      //            conjunction2.add(Restrictions.eq("parentPermission.account", permittedAccount));
      //
      //            Conjunction conjunction3 = Restrictions.conjunction();
      //            conjunction3.add(Restrictions.eq("parentPermission.permissionType",
      // ApplicationConstants.FOLDER_PERMISSION_MANAGER));
      //            conjunction3.add(Restrictions.eq("parentPermission.account", permittedAccount));

      //            disjunction.add(conjunction3);
      //            disjunction.add(Restrictions.ne("parentPermission.account", permittedAccount));
      //            disjunction.add(Restrictions.eq("parentPermission.permissionType",
      // ApplicationConstants.FOLDER_PERMISSION_MANAGER));

      //            disjunction.add(Restrictions.isNull("parentFolder.permissionList"));

      //            disjunction.add(Restrictions.eq("parentPermission.permissionType",
      // ApplicationConstants.FOLDER_PERMISSION_MANAGER));
      //            disjunction.add(Restrictions.ne("parentPermission.account", permittedAccount));

      crit.add(disjunction);

      folderList = crit.list();

      // start - get children for each child (trigger lazy fetch)
      for (DmFolder folderTmp : folderList) {
        if (folderTmp.getChildList() != null) {
          folderTmp.getChildList().size();
        }
      }
      // end - get children for each child (trigger lazy fetch)
    }

    return folderList;
  }
Ejemplo n.º 23
0
 @Override
 public Long count(DetachedCriteria criteria) {
   criteria.setProjection(Projections.rowCount());
   return DataAccessUtils.longResult(ht.findByCriteria(criteria));
 }
Ejemplo n.º 24
0
  @Override
  public List<OnmsAssetRecord> getDistinctProperties() {
    DetachedCriteria criteria = DetachedCriteria.forClass(OnmsAssetRecord.class);
    ProjectionList projList = Projections.projectionList();

    projList.add(
        Projections.alias(Projections.property("additionalhardware"), "additionalhardware"));
    projList.add(Projections.alias(Projections.property("address1"), "address1"));
    projList.add(Projections.alias(Projections.property("address2"), "address2"));
    projList.add(Projections.alias(Projections.property("admin"), "admin"));
    projList.add(Projections.alias(Projections.property("assetNumber"), "assetNumber"));
    projList.add(Projections.alias(Projections.property("autoenable"), "autoenable"));
    projList.add(Projections.alias(Projections.property("building"), "building"));
    projList.add(Projections.alias(Projections.property("category"), "category"));
    projList.add(Projections.alias(Projections.property("circuitId"), "circuitId"));
    projList.add(Projections.alias(Projections.property("city"), "city"));
    projList.add(Projections.alias(Projections.property("comment"), "comment"));
    projList.add(Projections.alias(Projections.property("connection"), "connection"));
    projList.add(Projections.alias(Projections.property("cpu"), "cpu"));
    projList.add(Projections.alias(Projections.property("department"), "department"));
    projList.add(Projections.alias(Projections.property("description"), "description"));
    projList.add(Projections.alias(Projections.property("displayCategory"), "displayCategory"));
    projList.add(Projections.alias(Projections.property("division"), "division"));
    projList.add(Projections.alias(Projections.property("enable"), "enable"));
    projList.add(Projections.alias(Projections.property("floor"), "floor"));
    projList.add(Projections.alias(Projections.property("hdd1"), "hdd1"));
    projList.add(Projections.alias(Projections.property("hdd2"), "hdd2"));
    projList.add(Projections.alias(Projections.property("hdd3"), "hdd3"));
    projList.add(Projections.alias(Projections.property("hdd4"), "hdd4"));
    projList.add(Projections.alias(Projections.property("hdd5"), "hdd5"));
    projList.add(Projections.alias(Projections.property("hdd6"), "hdd6"));
    projList.add(Projections.alias(Projections.property("inputpower"), "inputpower"));
    projList.add(Projections.alias(Projections.property("lease"), "lease"));
    projList.add(Projections.alias(Projections.property("maintcontract"), "maintcontract"));
    projList.add(Projections.alias(Projections.property("manufacturer"), "manufacturer"));
    projList.add(Projections.alias(Projections.property("modelNumber"), "modelNumber"));
    projList.add(Projections.alias(Projections.property("notifyCategory"), "notifyCategory"));
    projList.add(Projections.alias(Projections.property("numpowersupplies"), "numpowersupplies"));
    projList.add(Projections.alias(Projections.property("operatingSystem"), "operatingSystem"));
    projList.add(Projections.alias(Projections.property("pollerCategory"), "pollerCategory"));
    projList.add(Projections.alias(Projections.property("port"), "port"));
    projList.add(Projections.alias(Projections.property("rack"), "rack"));
    projList.add(Projections.alias(Projections.property("ram"), "ram"));
    projList.add(Projections.alias(Projections.property("region"), "region"));
    projList.add(Projections.alias(Projections.property("room"), "room"));
    projList.add(Projections.alias(Projections.property("serialNumber"), "serialNumber"));
    projList.add(Projections.alias(Projections.property("slot"), "slot"));
    projList.add(Projections.alias(Projections.property("snmpcommunity"), "snmpcommunity"));
    projList.add(Projections.alias(Projections.property("state"), "state"));
    projList.add(Projections.alias(Projections.property("storagectrl"), "storagectrl"));
    projList.add(Projections.alias(Projections.property("supportPhone"), "supportPhone"));
    projList.add(Projections.alias(Projections.property("thresholdCategory"), "thresholdCategory"));
    projList.add(Projections.alias(Projections.property("username"), "username"));
    projList.add(Projections.alias(Projections.property("vendor"), "vendor"));
    projList.add(Projections.alias(Projections.property("vendorAssetNumber"), "vendorAssetNumber"));
    projList.add(Projections.alias(Projections.property("vendorFax"), "vendorFax"));
    projList.add(Projections.alias(Projections.property("vendorPhone"), "vendorPhone"));
    projList.add(Projections.alias(Projections.property("zip"), "zip"));

    criteria.setProjection(Projections.distinct(projList));
    criteria.setResultTransformer(Transformers.aliasToBean(OnmsAssetRecord.class));

    @SuppressWarnings("unchecked")
    List<OnmsAssetRecord> result = getHibernateTemplate().findByCriteria(criteria);
    return result;
  }
 /* (non-Javadoc)
  * @see com.mg.framework.api.orm.DetachedCriteria#setProjection(com.mg.framework.api.orm.Projection)
  */
 @Override
 public DetachedCriteria setProjection(Projection projection) {
   delegate.setProjection(((GenericProjectionImpl) projection).getHibernateProjection());
   return this;
 }
  public List<RecepcionMx> getRecepcionesByFiltro(FiltroMx filtro) {
    Session session = sessionFactory.getCurrentSession();
    Soundex varSoundex = new Soundex();
    Criteria crit = session.createCriteria(RecepcionMx.class, "recepcion");
    crit.createAlias("recepcion.tomaMx", "tomaMx");
    crit.createAlias("tomaMx.estadoMx", "estado");
    // crit.createAlias("orden.idTomaMx", "tomaMx");
    crit.createAlias("tomaMx.idNotificacion", "notifi");
    // siempre se tomam las muestras que no estan anuladas
    crit.add(
        Restrictions.and(
            Restrictions.eq("tomaMx.anulada", false))); // y las ordenes en estado según filtro
    if (filtro.getCodEstado() != null) {
      if (filtro.getIncluirTraslados()) {
        crit.add(
            Restrictions.or(Restrictions.eq("estado.codigo", filtro.getCodEstado()).ignoreCase())
                .add(Restrictions.or(Restrictions.eq("estado.codigo", "ESTDMX|TRAS"))));
      } else {
        crit.add(
            Restrictions.and(
                Restrictions.eq("estado.codigo", filtro.getCodEstado().toLowerCase())
                    .ignoreCase()));
      }
    }

    // se filtra por nombre y apellido persona
    if (filtro.getNombreApellido() != null) {
      // crit.createAlias("notifi.persona", "person");
      String[] partes = filtro.getNombreApellido().split(" ");
      String[] partesSnd = filtro.getNombreApellido().split(" ");
      for (int i = 0; i < partes.length; i++) {
        try {
          partesSnd[i] = varSoundex.encode(partes[i]);
        } catch (IllegalArgumentException e) {
          partesSnd[i] = "0000";
          e.printStackTrace();
        }
      }
      for (int i = 0; i < partes.length; i++) {
        Junction conditGroup = Restrictions.disjunction();
        conditGroup
            .add(
                Subqueries.propertyIn(
                    "notifi.persona.personaId",
                    DetachedCriteria.forClass(SisPersona.class, "person")
                        .add(
                            Restrictions.or(
                                    Restrictions.ilike(
                                        "person.primerNombre", "%" + partes[i] + "%"))
                                .add(
                                    Restrictions.or(
                                            Restrictions.ilike(
                                                "person.primerApellido", "%" + partes[i] + "%"))
                                        .add(
                                            Restrictions.or(
                                                    Restrictions.ilike(
                                                        "person.segundoNombre",
                                                        "%" + partes[i] + "%"))
                                                .add(
                                                    Restrictions.or(
                                                            Restrictions.ilike(
                                                                "person.segundoApellido",
                                                                "%" + partes[i] + "%"))
                                                        .add(
                                                            Restrictions.or(
                                                                Restrictions.ilike(
                                                                    "person.sndNombre",
                                                                    "%" + partesSnd[i] + "%")))))))
                        .setProjection(Property.forName("personaId"))))
            .add(
                Subqueries.propertyIn(
                    "notifi.solicitante.idSolicitante",
                    DetachedCriteria.forClass(Solicitante.class, "solicitante")
                        .add(Restrictions.ilike("solicitante.nombre", "%" + partes[i] + "%"))
                        .setProjection(Property.forName("idSolicitante"))));

        crit.add(conditGroup);
      }
    }
    // se filtra por SILAIS
    if (filtro.getCodSilais() != null) {
      crit.createAlias("notifi.codSilaisAtencion", "silais");
      crit.add(
          Restrictions.and(Restrictions.eq("silais.codigo", Long.valueOf(filtro.getCodSilais()))));
    }
    // se filtra por unidad de salud
    if (filtro.getCodUnidadSalud() != null) {
      crit.createAlias("notifi.codUnidadAtencion", "unidadS");
      crit.add(
          Restrictions.and(
              Restrictions.eq("unidadS.codigo", Long.valueOf(filtro.getCodUnidadSalud()))));
    }
    // Se filtra por rango de fecha de toma de muestra
    if (filtro.getFechaInicioTomaMx() != null && filtro.getFechaFinTomaMx() != null) {
      crit.add(
          Restrictions.and(
              Restrictions.between(
                  "tomaMx.fechaHTomaMx",
                  filtro.getFechaInicioTomaMx(),
                  filtro.getFechaFinTomaMx())));
    }
    // Se filtra por rango de fecha de recepción
    if (filtro.getFechaInicioRecep() != null && filtro.getFechaFinRecep() != null) {
      crit.add(
          Restrictions.and(
              Restrictions.between(
                  "recepcion.fechaHoraRecepcion",
                  filtro.getFechaInicioRecep(),
                  filtro.getFechaFinRecep())));
    }
    // se filtra por tipo de muestra
    if (filtro.getCodTipoMx() != null) {
      crit.add(
          Restrictions.and(
              Restrictions.eq(
                  "tomaMx.codTipoMx.idTipoMx", Integer.valueOf(filtro.getCodTipoMx()))));
    }
    // se filtra por area que procesa
    /*if (filtro.getIdAreaProcesa()!=null){
        crit.createAlias("orden.codExamen", "examen");
        crit.add( Restrictions.and(
                        Restrictions.eq("examen.area.idArea", Integer.valueOf(filtro.getIdAreaProcesa())))
        );
    }*/

    // Se filtra por rango de fecha de recepcion en laboratorio
    if (filtro.getFechaInicioRecepLab() != null && filtro.getFechaFinRecepLab() != null) {
      crit.add(
          Subqueries.propertyIn(
              "recepcion.idRecepcion",
              DetachedCriteria.forClass(RecepcionMxLab.class)
                  .createAlias("recepcionMx", "recepcionGral")
                  .add(
                      Restrictions.between(
                          "fechaHoraRecepcion",
                          filtro.getFechaInicioRecepLab(),
                          filtro.getFechaFinRecepLab()))
                  .setProjection(Property.forName("recepcionGral.idRecepcion"))));
    }

    if (filtro.getIncluirMxInadecuada() != null && filtro.getIncluirMxInadecuada()) {
      crit.add(
          Restrictions.or(Restrictions.isNull("recepcion.calidadMx.codigo"))
              .add(Restrictions.or(Restrictions.ne("recepcion.calidadMx.codigo", "CALIDMX|IDC"))));
    }
    if (filtro.getCodigoUnicoMx() != null) {
      crit.add(
          Restrictions.or(Restrictions.eq("tomaMx.codigoUnicoMx", filtro.getCodigoUnicoMx()))
              .add(
                  Restrictions.or(Restrictions.eq("tomaMx.codigoLab", filtro.getCodigoUnicoMx()))));
    }

    // se filtra por tipo de solicitud
    if (filtro.getCodTipoSolicitud() != null) {
      if (filtro.getCodTipoSolicitud().equals("Estudio")) {
        crit.add(
            Subqueries.propertyIn(
                "tomaMx.idTomaMx",
                DetachedCriteria.forClass(DaSolicitudEstudio.class)
                    .createAlias("idTomaMx", "toma")
                    .setProjection(Property.forName("toma.idTomaMx"))));
      } else {
        crit.add(
            Subqueries.propertyIn(
                "tomaMx.idTomaMx",
                DetachedCriteria.forClass(DaSolicitudDx.class)
                    .createAlias("idTomaMx", "toma")
                    .add(
                        Subqueries.propertyIn(
                            "labProcesa.codigo",
                            DetachedCriteria.forClass(AutoridadLaboratorio.class)
                                .createAlias("laboratorio", "labautorizado")
                                .createAlias("user", "usuario")
                                .add(
                                    Restrictions.eq(
                                        "pasivo", false)) // autoridad laboratorio activa
                                .add(
                                    Restrictions.and(
                                        Restrictions.eq(
                                            "usuario.username",
                                            filtro.getNombreUsuario()))) // usuario
                                .setProjection(Property.forName("labautorizado.codigo"))))
                    .setProjection(Property.forName("toma.idTomaMx"))));
      }
    }

    // nombre solicitud
    if (filtro.getNombreSolicitud() != null) {
      if (filtro.getCodTipoSolicitud() != null) {
        if (filtro.getCodTipoSolicitud().equals("Estudio")) {
          crit.add(
              Subqueries.propertyIn(
                  "solicitudtomaMx.idTomaMx",
                  DetachedCriteria.forClass(DaSolicitudEstudio.class)
                      .createAlias("tipoEstudio", "estudio")
                      .add(
                          Restrictions.ilike(
                              "estudio.nombre", "%" + filtro.getNombreSolicitud() + "%"))
                      .createAlias("idTomaMx", "toma")
                      .setProjection(Property.forName("toma.idTomaMx"))));
        } else {
          crit.add(
              Subqueries.propertyIn(
                  "tomaMx.idTomaMx",
                  DetachedCriteria.forClass(DaSolicitudDx.class)
                      .createAlias("codDx", "dx")
                      .add(Restrictions.ilike("dx.nombre", "%" + filtro.getNombreSolicitud() + "%"))
                      .createAlias("idTomaMx", "toma")
                      .setProjection(Property.forName("toma.idTomaMx"))));
        }
      } else {

        Junction conditGroup = Restrictions.disjunction();
        conditGroup
            .add(
                Subqueries.propertyIn(
                    "tomaMx.idTomaMx",
                    DetachedCriteria.forClass(DaSolicitudEstudio.class)
                        .createAlias("tipoEstudio", "estudio")
                        .add(
                            Restrictions.ilike(
                                "estudio.nombre", "%" + filtro.getNombreSolicitud() + "%"))
                        .createAlias("idTomaMx", "toma")
                        .setProjection(Property.forName("toma.idTomaMx"))))
            .add(
                Subqueries.propertyIn(
                    "tomaMx.idTomaMx",
                    DetachedCriteria.forClass(DaSolicitudDx.class)
                        .createAlias("codDx", "dx")
                        .add(
                            Restrictions.ilike(
                                "dx.nombre", "%" + filtro.getNombreSolicitud() + "%"))
                        .createAlias("idTomaMx", "toma")
                        .setProjection(Property.forName("toma.idTomaMx"))));

        crit.add(conditGroup);
      }
    }
    // se filtra que usuario tenga autorizado laboratorio al que se envio la muestra desde ALERTA
    /*if (filtro.getNombreUsuario()!=null) {
        crit.createAlias("tomaMx.envio","envioMx");
        crit.add(Subqueries.propertyIn("envioMx.laboratorioDestino.codigo", DetachedCriteria.forClass(AutoridadLaboratorio.class)
                .createAlias("laboratorio", "labautorizado")
                .createAlias("user", "usuario")
                .add(Restrictions.eq("pasivo",false)) //autoridad laboratorio activa
                .add(Restrictions.and(Restrictions.eq("usuario.username",filtro.getNombreUsuario()))) //usuario
                .setProjection(Property.forName("labautorizado.codigo"))));

    }*/
    if (filtro.getCodEstado() != null) {
      if (filtro
          .getCodEstado()
          .equalsIgnoreCase("ESTDMX|EPLAB")) { // significa que es recepción en laboratorio
        // Se filtra que el área a la que pertenece la solicitud este asociada al usuario
        // autenticado
        Junction conditGroup = Restrictions.disjunction();

        conditGroup
            .add(
                Subqueries.propertyIn(
                    "tomaMx.idTomaMx",
                    DetachedCriteria.forClass(DaSolicitudEstudio.class)
                        .createAlias("tipoEstudio", "estudio")
                        .createAlias("estudio.area", "area")
                        .add(
                            Subqueries.propertyIn(
                                "area.idArea",
                                DetachedCriteria.forClass(AutoridadArea.class)
                                    .add(Restrictions.eq("pasivo", false)) // autoridad area activa
                                    .add(
                                        Restrictions.and(
                                            Restrictions.eq(
                                                "user.username",
                                                filtro.getNombreUsuario()))) // usuario
                                    .setProjection(Property.forName("area.idArea"))))
                        .createAlias("idTomaMx", "toma")
                        .setProjection(Property.forName("idTomaMx.idTomaMx"))))
            .add(
                Subqueries.propertyIn(
                    "tomaMx.idTomaMx",
                    DetachedCriteria.forClass(DaSolicitudDx.class)
                        .createAlias("codDx", "dx")
                        .createAlias("dx.area", "area")
                        .add(
                            Subqueries.propertyIn(
                                "area.idArea",
                                DetachedCriteria.forClass(AutoridadArea.class)
                                    .add(Restrictions.eq("pasivo", false)) // autoridad area activa
                                    .add(
                                        Restrictions.and(
                                            Restrictions.eq(
                                                "user.username",
                                                filtro.getNombreUsuario()))) // usuario
                                    .setProjection(Property.forName("area.idArea"))))
                        .createAlias("idTomaMx", "toma")
                        .setProjection(Property.forName("toma.idTomaMx"))));

        crit.add(conditGroup);
      }
    }

    // filtro que las rutinas pertenezcan al laboratorio del usuario que consulta
    crit.createAlias("recepcion.labRecepcion", "labRecep");
    crit.add(
        Subqueries.propertyIn(
            "labRecep.codigo",
            DetachedCriteria.forClass(AutoridadLaboratorio.class)
                .createAlias("laboratorio", "labautorizado")
                .createAlias("user", "usuario")
                .add(Restrictions.eq("pasivo", false)) // autoridad laboratorio activa
                .add(
                    Restrictions.and(
                        Restrictions.eq("usuario.username", filtro.getNombreUsuario()))) // usuario
                .setProjection(Property.forName("labautorizado.codigo"))));

    // sólo la última recepción de cada muestra

    DetachedCriteria maxDateQuery = DetachedCriteria.forClass(RecepcionMx.class);
    maxDateQuery.createAlias("tomaMx", "mx");
    maxDateQuery.add(Restrictions.eqProperty("mx.idTomaMx", "tomaMx.idTomaMx"));
    maxDateQuery.setProjection(Projections.max("fechaHoraRecepcion"));
    crit.add(Property.forName("fechaHoraRecepcion").eq(maxDateQuery));

    // filtro sólo control calidad en el laboratio del usuario
    if (filtro.getControlCalidad() != null) {
      if (filtro
          .getControlCalidad()) { // si hay filtro por control de calidad y es "Si", sólo incluir
                                  // rutinas
        crit.add(
            Subqueries.propertyIn(
                "tomaMx.idTomaMx",
                DetachedCriteria.forClass(DaSolicitudDx.class)
                    .add(Restrictions.eq("controlCalidad", filtro.getControlCalidad()))
                    .createAlias("idTomaMx", "toma")
                    .add(
                        Subqueries.propertyIn(
                            "labProcesa.codigo",
                            DetachedCriteria.forClass(AutoridadLaboratorio.class)
                                .createAlias("laboratorio", "labautorizado")
                                .createAlias("user", "usuario")
                                .add(
                                    Restrictions.eq(
                                        "pasivo", false)) // autoridad laboratorio activa
                                .add(
                                    Restrictions.and(
                                        Restrictions.eq(
                                            "usuario.username",
                                            filtro.getNombreUsuario()))) // usuario
                                .setProjection(Property.forName("labautorizado.codigo"))))
                    .setProjection(Property.forName("toma.idTomaMx"))));
      } else { // si hay filtro por control de calidad y es "No", siempre incluir los estudios
        Junction conditGroup = Restrictions.disjunction();
        conditGroup
            .add(
                Subqueries.propertyIn(
                    "tomaMx.idTomaMx",
                    DetachedCriteria.forClass(DaSolicitudDx.class)
                        .add(Restrictions.eq("controlCalidad", filtro.getControlCalidad()))
                        .createAlias("idTomaMx", "toma")
                        .add(
                            Subqueries.propertyIn(
                                "labProcesa.codigo",
                                DetachedCriteria.forClass(AutoridadLaboratorio.class)
                                    .createAlias("laboratorio", "labautorizado")
                                    .createAlias("user", "usuario")
                                    .add(
                                        Restrictions.eq(
                                            "pasivo", false)) // autoridad laboratorio activa
                                    .add(
                                        Restrictions.and(
                                            Restrictions.eq(
                                                "usuario.username",
                                                filtro.getNombreUsuario()))) // usuario
                                    .setProjection(Property.forName("labautorizado.codigo"))))
                        .setProjection(Property.forName("toma.idTomaMx"))))
            .add(
                Restrictions.or(
                    Subqueries.propertyIn(
                        "tomaMx.idTomaMx",
                        DetachedCriteria.forClass(DaSolicitudEstudio.class)
                            .createAlias("idTomaMx", "idTomaMx")
                            .setProjection(Property.forName("idTomaMx.idTomaMx")))));
        crit.add(conditGroup);
      }
    }
    // filtro para sólo solicitudes aprobadas
    if (filtro.getSolicitudAprobada() != null) {
      Junction conditGroup = Restrictions.disjunction();
      conditGroup
          .add(
              Subqueries.propertyIn(
                  "tomaMx.idTomaMx",
                  DetachedCriteria.forClass(DaSolicitudEstudio.class)
                      .add(Restrictions.eq("aprobada", filtro.getSolicitudAprobada()))
                      .createAlias("idTomaMx", "toma")
                      .setProjection(Property.forName("toma.idTomaMx"))))
          .add(
              Subqueries.propertyIn(
                  "tomaMx.idTomaMx",
                  DetachedCriteria.forClass(DaSolicitudDx.class)
                      .add(Restrictions.eq("aprobada", filtro.getSolicitudAprobada()))
                      // .add(Restrictions.eq("controlCalidad",false)) ¿¿¿¿¿¿¿¿¿?????????????
                      .createAlias("idTomaMx", "toma")
                      .setProjection(Property.forName("toma.idTomaMx"))));

      crit.add(conditGroup);
    }

    return crit.list();
  }
Ejemplo n.º 27
0
  @Override
  public Iterator<Item> findByMetadataQuery(
      Context context,
      List<List<MetadataField>> listFieldList,
      List<String> query_op,
      List<String> query_val,
      List<UUID> collectionUuids,
      String regexClause,
      int offset,
      int limit)
      throws SQLException {
    Criteria criteria = createCriteria(context, Item.class, "item");
    criteria.setFirstResult(offset);
    criteria.setMaxResults(limit);

    if (!collectionUuids.isEmpty()) {
      DetachedCriteria dcollCriteria = DetachedCriteria.forClass(Collection.class, "coll");
      dcollCriteria.setProjection(Projections.property("coll.id"));
      dcollCriteria.add(Restrictions.eqProperty("coll.id", "item.owningCollection"));
      dcollCriteria.add(Restrictions.in("coll.id", collectionUuids));
      criteria.add(Subqueries.exists(dcollCriteria));
    }

    int index = Math.min(listFieldList.size(), Math.min(query_op.size(), query_val.size()));
    StringBuilder sb = new StringBuilder();

    for (int i = 0; i < index; i++) {
      OP op = OP.valueOf(query_op.get(i));
      if (op == null) {
        log.warn("Skipping Invalid Operator: " + query_op.get(i));
        continue;
      }

      if (op == OP.matches || op == OP.doesnt_match) {
        if (regexClause.isEmpty()) {
          log.warn("Skipping Unsupported Regex Operator: " + query_op.get(i));
          continue;
        }
      }

      DetachedCriteria subcriteria = DetachedCriteria.forClass(MetadataValue.class, "mv");
      subcriteria.add(Property.forName("mv.dSpaceObject").eqProperty("item.id"));
      subcriteria.setProjection(Projections.property("mv.dSpaceObject"));

      if (!listFieldList.get(i).isEmpty()) {
        subcriteria.add(Restrictions.in("metadataField", listFieldList.get(i)));
      }

      sb.append(op.name() + " ");
      if (op == OP.equals || op == OP.not_equals) {
        subcriteria.add(Property.forName("mv.value").eq(query_val.get(i)));
        sb.append(query_val.get(i));
      } else if (op == OP.like || op == OP.not_like) {
        subcriteria.add(Property.forName("mv.value").like(query_val.get(i)));
        sb.append(query_val.get(i));
      } else if (op == OP.contains || op == OP.doesnt_contain) {
        subcriteria.add(Property.forName("mv.value").like("%" + query_val.get(i) + "%"));
        sb.append(query_val.get(i));
      } else if (op == OP.matches || op == OP.doesnt_match) {
        subcriteria.add(
            Restrictions.sqlRestriction(regexClause, query_val.get(i), StandardBasicTypes.STRING));
        sb.append(query_val.get(i));
      }

      if (op == OP.exists
          || op == OP.equals
          || op == OP.like
          || op == OP.contains
          || op == OP.matches) {
        criteria.add(Subqueries.exists(subcriteria));
      } else {
        criteria.add(Subqueries.notExists(subcriteria));
      }
    }
    log.debug(String.format("Running custom query with %d filters", index));

    return list(criteria).iterator();
  }
Ejemplo n.º 28
0
 public void setProjection(Property property) {
   detachedCriteria.setProjection(property);
 }
Ejemplo n.º 29
0
 public List<?> getAdminNameList() { // 获得管理员的姓名列表
   DetachedCriteria criteria = DetachedCriteria.forClass(Admin.class);
   criteria.setProjection((Projections.property("name")));
   List<?> list = getHibernateTemplate().findByCriteria(criteria);
   return list;
 }