Пример #1
0
  @Override
  public Long countConceptsAlignedToExtThes(String idThesaurus) {
    DetachedCriteria alignmentCriteria =
        DetachedCriteria.forClass(Alignment.class, "al")
            .add(Restrictions.isNotNull("al.externalTargetThesaurus"))
            .setProjection(
                Projections.projectionList()
                    .add(Projections.property(AL_SOURCE_CONCEPT_IDENTIFIER)));

    DetachedCriteria conceptCriteria =
        DetachedCriteria.forClass(ThesaurusConcept.class, "stc")
            .add(Restrictions.eq("stc.thesaurus.identifier", idThesaurus))
            .setProjection(
                Projections.projectionList().add(Projections.property("stc.identifier")));

    Criteria criteria =
        getCurrentSession()
            .createCriteria(ThesaurusConcept.class, "tc")
            .add(
                Restrictions.and(
                    Subqueries.propertyIn(TC_IDENTIFIER, alignmentCriteria),
                    Subqueries.propertyIn(TC_IDENTIFIER, conceptCriteria)))
            .setProjection(Projections.rowCount());
    return (Long) criteria.list().get(0);
  }
Пример #2
0
  private Criteria getCriteriaByThesaurusAndTopConcept(
      Thesaurus thesaurus, boolean topConcept, String like) {
    Criteria criteria = getCurrentSession().createCriteria(ThesaurusConcept.class, "tc");

    if (null != like) {
      criteria =
          getCurrentSession()
              .createCriteria(ThesaurusTerm.class, "tt")
              .add(Restrictions.isNotNull("tt.concept"))
              .createCriteria("concept", "tc", JoinType.RIGHT_OUTER_JOIN);

      criteria
          .setProjection(
              Projections.projectionList()
                  .add(Projections.property("tt.lexicalValue"))
                  .add(Projections.property("tc.identifier").as("identifier")))
          .setResultTransformer(Transformers.aliasToBean(ThesaurusConcept.class));
      conceptNameIsLike(criteria, like);
    }

    selectThesaurus(criteria, thesaurus.getIdentifier());
    selectOrphans(criteria, !topConcept);
    selectNoParents(criteria);
    return criteria;
  }
  @SuppressWarnings("unchecked")
  protected List<Object[]> getSavedSearchDetails(Long savedSearchQueryID, String type) {
    SavedSearchRetriever.AlertType alertType = SavedSearchRetriever.AlertType.valueOf(type);

    DetachedCriteria criteria =
        DetachedCriteria.forClass(UserProfile.class)
            .setProjection(
                Projections.distinct(
                    Projections.projectionList()
                        .add(Projections.property("ss.ID"))
                        .add(Projections.property("email"))
                        .add(Projections.property("ss.searchName"))))
            .createAlias("savedSearches", "ss")
            .createAlias("ss.searchQuery", "q")
            .add(Restrictions.eq("q.ID", savedSearchQueryID));

    if (alertType == SavedSearchRetriever.AlertType.WEEKLY) {
      criteria.add(Restrictions.eq("ss.weekly", true));
    }

    if (alertType == SavedSearchRetriever.AlertType.MONTHLY) {
      criteria.add(Restrictions.eq("ss.monthly", true));
    }

    return (List<Object[]>) hibernateTemplate.findByCriteria(criteria);
  }
  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");
          }
        }
      }
    }
  }
Пример #5
0
  @SuppressWarnings("unchecked")
  private AnnotationView buildAnnotationView(Annotation annotation, boolean loadAllReplies) {
    Object values[];
    try {
      values =
          (Object[])
              hibernateTemplate
                  .findByCriteria(
                      DetachedCriteria.forClass(Article.class)
                          .add(Restrictions.eq("ID", annotation.getArticleID()))
                          .setProjection(
                              Projections.projectionList()
                                  .add(Projections.property("doi"))
                                  .add(Projections.property("title"))),
                      0,
                      1)
                  .get(0);

    } catch (IndexOutOfBoundsException e) {
      // this should never happen
      throw new IllegalStateException(
          "Annotation "
              + annotation.getID()
              + " pointed to an article that didn't exist;"
              + " articleID: "
              + annotation.getArticleID());
    }

    String articleDoi = (String) values[0];
    String articleTitle = (String) values[1];

    return buildAnnotationView(annotation, articleDoi, articleTitle, loadAllReplies);
  }
  public List<SessionTimeOutDTO> getSessionIDListBySID(Long sid) {
    List<SessionTimeOutDTO> dtoList = null;
    SessionTimeOutDTO dto = null;

    Session session = getSession();
    session.getTransaction().begin();

    Criteria criteria =
        session
            .createCriteria(SessionDetails.class, "sessionDetails")
            .add(Restrictions.eq("SID", sid));
    criteria.setProjection(
        Projections.projectionList()
            .add(Projections.property("SID").as("sid"))
            .add(Projections.property("sessionId").as("sessionId")));
    dto =
        (SessionTimeOutDTO)
            criteria
                .setResultTransformer(Transformers.aliasToBean(SessionTimeOutDTO.class))
                .uniqueResult();

    session.getTransaction().commit();
    session.close();

    dtoList = getList(dto);
    return dtoList;
  }
Пример #7
0
  @Override
  @Transactional(readOnly = true)
  public AnnotationView[] listAnnotationsNoReplies(
      final Long articleID,
      final Set<AnnotationType> annotationTypes,
      final AnnotationOrder order) {
    if (order == AnnotationOrder.MOST_RECENT_REPLY) {
      throw new IllegalArgumentException(
          "Cannot specify Most Recent Reply order type when replies are not being loaded up");
    }
    // Basic criteria
    DetachedCriteria criteria =
        DetachedCriteria.forClass(Annotation.class)
            .add(Restrictions.eq("articleID", articleID))
            .setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
    // restrict by type
    if (annotationTypes != null && !annotationTypes.isEmpty()) {
      criteria.add(Restrictions.in("type", annotationTypes));
    }
    switch (order) {
      case OLDEST_TO_NEWEST:
        criteria.addOrder(Order.asc("created"));
        break;
      case NEWEST_TO_OLDEST:
        criteria.addOrder(Order.desc("created"));
        break;
    }
    List annotationResults = hibernateTemplate.findByCriteria(criteria);
    // Don't want to call buildAnnotationView() here because that would involve finding the article
    // title and doi for each annotation,
    // when we only need to do it once. So load up the info we need to build annotation views here
    Object[] articleTitleAndDoi;
    try {
      articleTitleAndDoi =
          (Object[])
              hibernateTemplate
                  .findByCriteria(
                      DetachedCriteria.forClass(Article.class)
                          .add(Restrictions.eq("ID", articleID))
                          .setProjection(
                              Projections.projectionList()
                                  .add(Projections.property("doi"))
                                  .add(Projections.property("title"))),
                      0,
                      1)
                  .get(0);

    } catch (IndexOutOfBoundsException e) {
      throw new IllegalArgumentException("article " + articleID + " didn't exist");
    }
    String articleDoi = (String) articleTitleAndDoi[0];
    String articleTitle = (String) articleTitleAndDoi[1];

    List<AnnotationView> viewResults = new ArrayList<AnnotationView>(annotationResults.size());
    for (Object annotation : annotationResults) {
      viewResults.add(new AnnotationView((Annotation) annotation, articleDoi, articleTitle, null));
    }
    return viewResults.toArray(new AnnotationView[viewResults.size()]);
  }
  @Scheduled(fixedDelay = 60000)
  public void changeSessionStatus() {

    List<CurrentUsersDTO> allList = null;
    List<CurrentUsersDTO> activeList = null;

    String currentTime = getTime();
    String beforeTime = getBeforeTime();
    String beforeHeartBeatTime = getBeforeHeartBeatTime();

    Session session = getSession();
    session.getTransaction().begin();

    Criteria criteria =
        session
            .createCriteria(SessionDetails.class, "sessionDetails")
            .add(
                Restrictions.between(
                    "sessionDetails.heartBeatTime", beforeHeartBeatTime, currentTime))
            .add(Restrictions.between("sessionDetails.lastAccessTime", beforeTime, currentTime));
    criteria.addOrder(Order.asc("SID"));
    criteria.setProjection(
        Projections.projectionList()
            .add(Projections.property("SID").as("sid"))
            .add(Projections.property("lastAccessTime").as("lastAccessTime")));
    activeList =
        criteria.setResultTransformer(Transformers.aliasToBean(CurrentUsersDTO.class)).list();

    Criteria criteria1 = session.createCriteria(SessionDetails.class, "sessionDetails");
    criteria1.addOrder(Order.asc("SID"));
    criteria1.setProjection(
        Projections.projectionList()
            .add(Projections.property("SID").as("sid"))
            .add(Projections.property("lastAccessTime").as("lastAccessTime")));
    allList =
        criteria1.setResultTransformer(Transformers.aliasToBean(CurrentUsersDTO.class)).list();

    for (CurrentUsersDTO dto : allList) {
      try {
        SessionDetails sd = getById(dto.getSid());
        sd.setStatus("INACTIVE");
        saveSessionDetails(sd);
      } catch (Exception e) {
        System.out.println("E :" + e);
      }
    }

    for (CurrentUsersDTO dto : activeList) {
      try {
        SessionDetails sd = getById(dto.getSid());
        sd.setStatus("ACTIVE");
        saveSessionDetails(sd);
      } catch (Exception e) {
        System.out.println("E :" + e);
      }
    }
    session.getTransaction().commit();
    session.close();
  }
Пример #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;
 }
Пример #10
0
  // Create by JOB
  public List<User> getAllUserTrainee() {
    Criteria criteria = getSession().createCriteria(User.class);
    criteria.setProjection(
        Projections.projectionList()
            .add(Projections.property("empId"), "empId")
            .add(Projections.property("thFname"), "thFname")
            .add(Projections.property("thLname"), "thLname"));
    Criterion cri = Restrictions.eq("aptId", 1);
    Criterion cri2 = Restrictions.eq("aptId", 2);
    criteria.add(Restrictions.or(cri, cri2));

    criteria.setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);
    List<User> allUserTrainee = criteria.list();
    return allUserTrainee;
  }
Пример #11
0
  @Override
  @Transactional
  public Long createReply(
      UserProfile user, Long parentId, String title, String body, @Nullable String ciStatement) {
    if (parentId == null) {
      throw new IllegalArgumentException("Attempting to create reply with null parent id");
    }
    log.debug("Creating reply to {}; title: {}; body: {}", new Object[] {parentId, title, body});
    Long articleID;
    try {
      articleID =
          (Long)
              hibernateTemplate
                  .findByCriteria(
                      DetachedCriteria.forClass(Annotation.class)
                          .add(Restrictions.eq("ID", parentId))
                          .setProjection(Projections.property("articleID")),
                      0,
                      1)
                  .get(0);
    } catch (IndexOutOfBoundsException e) {
      throw new IllegalArgumentException("Invalid annotation id: " + parentId);
    }

    Annotation reply = new Annotation(user, AnnotationType.REPLY, articleID);
    reply.setParentID(parentId);
    reply.setTitle(title);
    reply.setBody(body);
    reply.setCompetingInterestBody(ciStatement);
    reply.setAnnotationUri(URIGenerator.generate(reply));
    return (Long) hibernateTemplate.save(reply);
  }
Пример #12
0
  public List<UserCountDTO> getCurrentUserCountList(
      String sortField, int order, int start, int gridTableSize, String searchq) throws Exception {
    int count = start;

    List<UserCountDTO> dtoList = null;
    List<UserCountDTO> dtoListCount = new ArrayList<UserCountDTO>();

    Session session = getSession();
    session.getTransaction().begin();

    Criteria criteria =
        session
            .createCriteria(SessionDetails.class, "sessionDetails")
            .add(Restrictions.eq("status", "ACTIVE"));
    criteria.addOrder(Order.asc("SID"));
    criteria.setFirstResult(start).setMaxResults(gridTableSize);
    criteria.setProjection(Projections.projectionList().add(Projections.property("SID").as("sid")));

    dtoList = criteria.setResultTransformer(Transformers.aliasToBean(UserCountDTO.class)).list();
    session.getTransaction().commit();
    session.close();

    if (dtoList.size() > 0) {
      for (UserCountDTO dto : dtoList) {
        dto.setCountId(count + 1);
        dtoListCount.add(dto);
        count += 1;
      }
    }
    return dtoListCount;
  }
Пример #13
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();
  }
Пример #14
0
 public List<Entidad> obtenerEntidadesYaPoliticas(Long idRed) {
   List<Entidad> entidades =
       this.criteriaEntidadesPoliticas(idRed)
           .setProjection(Projections.projectionList().add(Projections.property("entidad")))
           .list();
   return entidades;
 }
Пример #15
0
  @SuppressWarnings("unchecked")
  @Override
  public Object tryAndFindLookupValue(
      final String systemName,
      final String tableName,
      final String columnName,
      final String lookupValue)
      throws ClassNotFoundException {

    final List<PhysicalToPhysicalLookupView> physicalLookups =
        getSession()
            .createCriteria(PhysicalToPhysicalLookupView.class)
            .add(Restrictions.eq("id.systemName", systemName))
            .add(Restrictions.eq("id.tableName", tableName))
            .add(Restrictions.eq("id.columnNume", columnName))
            .list();

    if (physicalLookups == null || physicalLookups.size() != 2) {
      // do nothing - return a warning if > 2
      return null;
    }

    String lookupSystem = "";
    String lookupTable = "";
    String lookupColumn = "";
    String projection = "";

    for (final PhysicalToPhysicalLookupView lookup : physicalLookups) {
      if (lookup.getId().getNameRuleType().equals(LOOKUP_KEY)) {
        lookupSystem = lookup.getId().getSystemName();
        lookupTable = lookup.getId().getLookupTable();
        lookupColumn = lookup.getId().getLookupColumn();
      }
      if (lookup.getId().getNameRuleType().equals(LOOKUP_VALUE)) {
        projection = lookup.getId().getLookupColumn();
      }
    }

    if (lookupSystem == null || lookupTable == null || lookupColumn == null || projection == null) {
      throw new RuntimeException(
          "Unable to create a lookup map for system name: "
              + systemName
              + " on table "
              + tableName
              + " with column "
              + columnName);
    }

    final Class<?> clazz = null; // explorer.getClass(lookupTable,
    // systemName.toLowerCase(),"com.equityopschange.systems");

    final Object lookedUpValue =
        getSession()
            .createCriteria(clazz)
            .add(Restrictions.eq(lookupColumn, lookupValue))
            .setProjection(Projections.property(projection))
            .uniqueResult();

    return lookedUpValue;
  }
 @Override
 public Long getCount(Retirement r, String ks, String js, String eq, String type) {
   Criteria criteria = buildCondition(r, ks, js, eq, type);
   ProjectionList proList = Projections.projectionList(); // 设置投影集合
   proList.add(Projections.property("sfzh"));
   criteria.setProjection(proList);
   return this.getCount(criteria);
 }
Пример #17
0
 @SuppressWarnings("unchecked")
 public List<String> listStringByFields(String field) {
   Criteria criteria = getCurrentSession().createCriteria(Titem.class);
   criteria.setProjection(Projections.distinct(Projections.property(field)));
   criteria.addOrder(Order.asc(field));
   List<String> list = criteria.list();
   return list;
 }
Пример #18
0
  public Collection<String> getAllMacs() {
    Criteria criteria = getSession().createCriteria(IpPoolManagement.class);
    ProjectionList projList = Projections.projectionList();
    projList.add(Projections.property(IpPoolManagement.MAC_PROPERTY));

    criteria.setProjection(projList);
    return criteria.list();
  }
Пример #19
0
 public static boolean checkIfEntityExists(
     Session session, Class classz, String idKey, String idValue) {
   return session
           .createCriteria(classz)
           .add(Restrictions.eq(idKey, idValue))
           .setProjection(Projections.property(idKey))
           .uniqueResult()
       != null;
 }
Пример #20
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);
  }
 public static void main(String[] args) {
   Session session = HibUtil.getSession();
   Criteria crit = session.createCriteria(Employee.class);
   crit.setProjection(Projections.property("empName"));
   List<String> names = crit.list();
   for (String name : names) {
     System.out.println(name);
   }
 }
 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;
 }
 @SuppressWarnings("unchecked")
 public List<GraffitiDTO> getByWriteDate(Date writeDate) throws DataAccessException {
   Criteria c =
       getCurrentSession()
           .createCriteria(Graffiti.class)
           .createAlias("member", "member")
           .add(Expression.ge("writeDate", writeDate))
           .addOrder(Order.asc("writeDate"))
           .setProjection(
               Projections.projectionList()
                   .add(Projections.property("id").as("id"))
                   .add(Projections.property("member.name").as("writerName"))
                   .add(Projections.property("member.avatar").as("writerAvatar"))
                   .add(Projections.property("contents").as("contents"))
                   .add(Projections.property("writeDate").as("writtenDate")))
           .setResultTransformer(new AliasToBeanResultTransformer(GraffitiDTO.class));
   return c.list();
 }
Пример #24
0
 @SuppressWarnings("unchecked")
 @Override
 public ResultList getUnique(String key, String query) {
   Criteria criteria = sessionFactory.getCurrentSession().createCriteria(PersonName.class);
   criteria.add(Restrictions.ilike(key, query + "%"));
   criteria.setProjection(Projections.distinct(Projections.property(key)));
   criteria.setMaxResults(20);
   return new ResultList(criteria.list());
 }
  @SuppressWarnings("unchecked")
  @Override
  public Collection<FuncionarioAreaTrabajoDTO> consultarFuncionarioAreaTrabajoPorAreaTrabajo(
      Integer codigoAreaTrabajo, String userId, Integer codigoCompania, String usuarioSesion)
      throws SICException {
    try {

      Criteria criteria =
          sessionFactory.getCurrentSession().createCriteria(FuncionarioAreaTrabajoDTO.class);
      criteria.setProjection(
          Projections.projectionList()
              .add(Projections.property("usuarioDTO.userId"), "funcionarioDTO.usuarioDTO.userId")
              .add(
                  Projections.property("usuarioDTO.userCompleteName"),
                  "funcionarioDTO.usuarioDTO.userCompleteName")
              .add(
                  Projections.property("usuarioDTO.userName"), "funcionarioDTO.usuarioDTO.userName")
              .add(
                  Projections.property("areaTrabajoDTO.nombreAreaTrabajo"),
                  "areaTrabajoDTO.nombreAreaTrabajo")
              .add(Projections.property("id.codigoCompania"), "id.codigoCompania")
              .add(Projections.property("id.codigoFuncionario"), "id.codigoFuncionario")
              .add(Projections.property("id.codigoAreaTrabajo"), "id.codigoAreaTrabajo"));

      criteria.createAlias("funcionarioDTO", "funcionarioDTO");
      criteria.createAlias("funcionarioDTO.usuarioDTO", "usuarioDTO");

      criteria.createAlias("areaTrabajoDTO", "areaTrabajoDTO");

      criteria.add(Restrictions.eq("estado", SICConstantes.ESTADO_ACTIVO_LITERAL));
      criteria.add(
          Restrictions.eq("funcionarioDTO.estadoFuncionario", SICConstantes.ESTADO_ACTIVO_LITERAL));
      criteria.add(
          Restrictions.eq("areaTrabajoDTO.estadoAreaTrabajo", SICConstantes.ESTADO_ACTIVO_LITERAL));

      criteria.add(Restrictions.eq("id.codigoCompania", codigoCompania));
      criteria.add(Restrictions.eq("areaTrabajoDTO.id.codigoAreaTrabajo", codigoAreaTrabajo));
      criteria.add(Restrictions.ne("usuarioDTO.userName", usuarioSesion));

      // si el usuario ingresa un nombre o usuario de un funcionario
      if (StringUtils.isNotEmpty(userId)) {
        Disjunction disjunction = Restrictions.disjunction();
        disjunction.add(Restrictions.ilike("usuarioDTO.userName", userId, MatchMode.ANYWHERE));
        disjunction.add(
            Restrictions.ilike("usuarioDTO.userCompleteName", userId, MatchMode.ANYWHERE));
        criteria.add(disjunction);
      }
      criteria.setResultTransformer(new DtoResultTransformer(FuncionarioAreaTrabajoDTO.class));

      Collection<FuncionarioAreaTrabajoDTO> funcionarioAreaTrabajoDTOCol = criteria.list();

      return funcionarioAreaTrabajoDTOCol;

    } catch (HibernateException e) {
      throw new SICException("Error consultarFuncionarioAreaTrabajoPorAreaTrabajo: ", e);
    } catch (Exception e) {
      throw new SICException("Error consultarFuncionarioAreaTrabajoPorAreaTrabajo ", e);
    }
  }
Пример #26
0
 @SuppressWarnings("unchecked")
 public List<String> getAllHomeDepartments(ObjectStatus status) {
   Criteria criteria = createCriteria();
   if (status != null) criteria.add(Restrictions.eq("objectStatus", status));
   criteria.add(Restrictions.isNotNull("departmentName"));
   criteria.setProjection(
       Projections.projectionList()
           .add(Projections.distinct(Projections.property("departmentName"))));
   return ((List<String>) criteria.list());
 }
Пример #27
0
 public List<Facturador> obtenerFacturadoresHabilitados(Long idRed) {
   HibernateEntityManager hem = (HibernateEntityManager) this.getEm().getDelegate();
   List<Facturador> facturadores =
       (List<Facturador>)
           hem.getSession()
               .createCriteria(HabilitacionFactRed.class)
               .add(Restrictions.eq("red", new Red(idRed)))
               .setProjection(Projections.projectionList().add(Projections.property("facturador")))
               .list();
   return facturadores;
 }
 @SuppressWarnings("unchecked")
 @Override
 public List<Integer> recuperarIdsOficinasDisponiveis(Integer idCursoSelecionado) {
   Criteria criteria = getSession().createCriteria(Oficina.class);
   if (idCursoSelecionado != null && !idCursoSelecionado.equals(0)) {
     criteria.createAlias("curso", "curso");
     criteria.add(Restrictions.eq("curso.id", idCursoSelecionado));
     criteria.setProjection(Projections.distinct(Projections.property("id")));
   }
   return criteria.list();
 }
  @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();
  }
Пример #30
0
  public List<Long> findOrderIds(Object... params) {
    Criteria criteria = createDefaultCriteria(OrderPurchase.class);
    criteria.setProjection(Projections.property("id"));

    handleSpecificOrderFetchMode(criteria, params);

    criteria.addOrder(Order.asc("dateCreate"));

    @SuppressWarnings("unchecked")
    List<Long> orderIds = criteria.list();
    return orderIds;
  }