Package javax.persistence.criteria

Examples of javax.persistence.criteria.CriteriaBuilder.desc()


        CriteriaBuilder cb = getCriteriaBuilder();
       
        List<Order> orders = new ArrayList<Order>();
        for (SingularAttribute<T, ?> attribute : attributes) {
            Path<?> selection = getRoot().get(attribute);
            Order order = asc ? cb.asc(selection) : cb.desc(selection);
            orders.add(order);
        }
        return getCriteriaQuery().orderBy(orders);
    }
   
View Full Code Here


                    }
                   
                    if (asc) {
                        sorts.add(builder.asc(pathToUse.get(key)));
                    } else {
                        sorts.add(builder.desc(pathToUse.get(key)));
                    }
                }
            }
           
            criteria.orderBy(sorts.toArray(new Order[sorts.size()]));
View Full Code Here

            {
                criteriaQuery.where((value != null) ? criteriaBuilder.equal(beanRoot.get(name), value) : criteriaBuilder.isNull(beanRoot.get(name)));
            }
            if (orderBy != null)
            {
                criteriaQuery.orderBy(ascending ? criteriaBuilder.asc(beanRoot.get(orderBy)) : criteriaBuilder.desc(beanRoot.get(orderBy)));
            }
           
            // invoke query
            Query query = entityManager.createQuery(criteriaQuery);
            List<? extends IBean> beansList = query.getResultList();
View Full Code Here

                }
                criteriaQuery.where(predicate);
            }
            if (orderBy != null)
            {
                criteriaQuery.orderBy(ascending ? criteriaBuilder.asc(beanRoot.get(orderBy)) : criteriaBuilder.desc(beanRoot.get(orderBy)));
            }
           
            // invoke query
            Query query = entityManager.createQuery(criteriaQuery);
            List<? extends IBean> beansList = query.getResultList();
View Full Code Here

      // cb.diff(root.<String> get("stoa"),sdf.parse(new
      // HpUfisCalendar().getCedaString()));

      cq.where(cb.and(filters.toArray(new Predicate[0])));
      if (ADID.A.equals(adid)) {
        cq.orderBy(cb.desc(root.<String> get("stoa")));
      } else {
        cq.orderBy(cb.desc(root.<String> get("stod")));
      }
      Query query = em.createQuery(cq);
      // List<BigDecimal> result = query.getResultList();
View Full Code Here

      cq.where(cb.and(filters.toArray(new Predicate[0])));
      if (ADID.A.equals(adid)) {
        cq.orderBy(cb.desc(root.<String> get("stoa")));
      } else {
        cq.orderBy(cb.desc(root.<String> get("stod")));
      }
      Query query = em.createQuery(cq);
      // List<BigDecimal> result = query.getResultList();
      List<Tuple> results = query.getResultList();
      if (results == null || results.size() == 0) {
View Full Code Here

      }
      filters.add(cb.not(cb.in(root.get("ftyp")).value('T').value('G')
          .value('X').value('N')));

      cq.where(cb.and(filters.toArray(new Predicate[0])));
      cq.orderBy(cb.desc(root.<String> get("stod")));
      Query query = em.createQuery(cq);
      // List<BigDecimal> result = query.getResultList();
      List<Tuple> results = query.getResultList();
      if (results == null || results.size() == 0) {
        LOG.warn("BELT: Cannot find flight from afttab");
View Full Code Here

      }
      filters.add(cb.not(cb.in(root.get("ftyp")).value('T').value('G')
          .value('X').value('N')));

      cq.where(cb.and(filters.toArray(new Predicate[0])));
      cq.orderBy(cb.desc(root.<String> get("stod")));

      Query query = em.createQuery(cq);
      // List<BigDecimal> result = query.getResultList();
      List<Tuple> results = query.getResultList();
      if (results == null || results.size() == 0) {
View Full Code Here

          ufisCalendarFrom.getCedaString(),
          ufisCalendarTo.getCedaString()));
      filters.add(cb.not(cb.in(root.get("ftyp")).value('T').value('G')));

      cq.where(cb.and(filters.toArray(new Predicate[0])));
      cq.orderBy(cb.desc(root.<String> get("regn")));
      Query query = em.createQuery(cq);
      List<Tuple> results = query.getResultList();
      if (results == null || results.size() == 0) {
        LOG.warn("No flight from afttab");
      } else if (results.size() > 0) {
View Full Code Here

            Root<JPACommit> from = query.from(JPACommit.class);

            query.select(from);
            Predicate[] predicates = analyzeParamMap(criteriaBuilder, from, param);
            query.where(criteriaBuilder.and(predicates));
            query.orderBy(criteriaBuilder.desc(from.get("timestamp")));

            TypedQuery<JPACommit> typedQuery = entityManager.createQuery(query).setMaxResults(1);
            try {
                return typedQuery.getSingleResult();
            } catch (NoResultException ex) {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.