Package javax.persistence.criteria

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


        cq.where(condition);
        cq.distinct(asc);
        if (asc) {
          cq.orderBy(cb.asc(c.get(orderby)));
        } else {
          cq.orderBy(cb.desc(c.get(orderby)));
        }
        TypedQuery<User> q = em.createQuery(cq);
        q.setFirstResult(start);
        q.setMaxResults(max);
        List<User> ll = q.getResultList();
View Full Code Here


        cq.where(condition, predicate);
        cq.distinct(asc);
        if (asc) {
          cq.orderBy(cb.asc(c.get(orderby)));
        } else {
          cq.orderBy(cb.desc(c.get(orderby)));
        }
        TypedQuery<User> q = em.createQuery(cq);
        q.setFirstResult(start);
        q.setMaxResults(max);
        List<User> contactsZ = q.getResultList();
View Full Code Here

      cq.where(condition);
      cq.distinct(asc);
      if (asc) {
        cq.orderBy(cb.asc(c.get(orderby)));
      } else {
        cq.orderBy(cb.desc(c.get(orderby)));
      }
      TypedQuery<Room> q = em.createQuery(cq);
      q.setFirstResult(start);
      q.setMaxResults(max);
      List<Room> ll = q.getResultList();
View Full Code Here

      cq.where(condition, subCondition);
      cq.distinct(asc);
      if (asc) {
        cq.orderBy(cb.asc(c.get(orderby)));
      } else {
        cq.orderBy(cb.desc(c.get(orderby)));
      }
      TypedQuery<Room> q = em.createQuery(cq);
      q.setFirstResult(start);
      q.setMaxResults(max);
      List<Room> ll = q.getResultList();
View Full Code Here

        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

  {
    final CriteriaBuilder builder = this.getEntityManager().getCriteriaBuilder();
    final CriteriaQuery<NewsEntry> criteriaQuery = builder.createQuery(NewsEntry.class);

    Root<NewsEntry> root = criteriaQuery.from(NewsEntry.class);
    criteriaQuery.orderBy(builder.desc(root.get("date")));

    TypedQuery<NewsEntry> typedQuery = this.getEntityManager().createQuery(criteriaQuery);
    return typedQuery.getResultList();
  }
View Full Code Here

        }
        if (codeFragment.getDatetime() != null) {
            predicates.add(builder.between(root.get(CodeFragment_.datetime), codeFragment.getDatetime(), new Date()));
        }

        criteria.where(predicates.toArray(new Predicate[0])).orderBy(builder.desc(root.get(CodeFragment_.datetime)));

        Query q = entityManager.createQuery(criteria);

        int totalRecords = q.getResultList().size();
View Full Code Here

        }
        final CompoundSelection<Tuple> selection = cb.tuple(requestDateByType, cb.count(requestRoot));
        cbQuery.select(selection)
                .where(whereClause)
                .groupBy(requestDateByType)
                .orderBy(cb.desc(requestDateByType));

        final TypedQuery<Tuple> query = _EntityManager.createQuery(cbQuery);
        List<Tuple> stats = query.getResultList();

        return Lists.transform(stats, new Function<Tuple, Pair<T, Integer>>() {
View Full Code Here

        Path<T> path = groupingPath.getPath(root);

        final Order order;
        switch (direction) {
            case DESC:
                order = cb.desc(path);
                break;
            case ASC:
                order = cb.asc(path);
                break;
            default:
View Full Code Here

        }
        if (codeFragment.getDatetime() != null) {
            predicates.add(builder.between(root.get(CodeFragment_.datetime), codeFragment.getDatetime(), new Date()));
        }

        criteria.where(predicates.toArray(new Predicate[predicates.size()])).orderBy(builder.desc(root.get(CodeFragment_.datetime)));

        Query q = entityManager.createQuery(criteria);

        int totalRecords = q.getResultList().size();
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.