Package javax.persistence.criteria

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


        }
        CriteriaBuilder cb = getEntityManager().getCriteriaBuilder();
        CriteriaQuery cq = cb.createQuery();
        Root<UserHD> z = cq.from(UserHD.class);
        cq.where(cb.equal(z.get(UserHD_.organization), o));
        cq.orderBy(cb.asc(z.get(UserHD_.name)));
        cq.select(z);
       
        return getEntityManager().createQuery(cq).getResultList();
       
    }
View Full Code Here


   
    public List<Priority> findAll() {
        CriteriaBuilder cb = getEntityManager().getCriteriaBuilder();
        CriteriaQuery cq = cb.createQuery();
        Root<Priority> h = cq.from(Priority.class);
        cq.orderBy(cb.asc(h.get(Priority_.id)));
        return getEntityManager().createQuery(cq).getResultList();
    }

  
  
View Full Code Here

        CriteriaQuery cq = cb.createQuery();
        Root<ServiceObject> s = cq.from(ServiceObject.class);
       
        cq.where(cb.equal(s.get(ServiceObject_.organization), curUser.getOrganization()));
       
        cq.orderBy(cb.asc(s.get(ServiceObject_.id)));
        cq.select(s);
       
        return getEntityManager().createQuery(cq).getResultList();

       
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

        Root<Inventory> inv = q.from(Inventory.class);
        q.select(inv);
        Expression<Integer> inStock = cb.diff(
                inv.get(Inventory_.supplied),
                inv.get(Inventory_.sold));
        q.orderBy(cb.asc(inStock));
       
        List<Inventory> result = em.createQuery(q)
                                   .setMaxResults(limit)
                                   .getResultList();
        commit();
View Full Code Here

            switch (constraint.getColumnSort())
            {

                case ASCENDING:

                    criteria.orderBy(builder.asc(propertyPath));
                    break;

                case DESCENDING:
                    criteria.orderBy(builder.desc(propertyPath));
                    break;
View Full Code Here

        // }
        SortOrderItem item = iter.next();
        Path<?> path = root.get(mt.getSingularAttribute(item.getProperty()));
        Direction direction = item.getDirection();
        if (direction == Direction.ASC) {
          orderList.add(cb.asc(path));
        } else if (direction == Direction.DESC) {
          orderList.add(cb.desc(path));
        } else if (direction == Direction.ASC_TRUNC) {
          orderList.add(cb.asc(cb.function("trunc", Path.class, path)));
        } else if (direction == Direction.DESC_TRUNC) {
View Full Code Here

        if (direction == Direction.ASC) {
          orderList.add(cb.asc(path));
        } else if (direction == Direction.DESC) {
          orderList.add(cb.desc(path));
        } else if (direction == Direction.ASC_TRUNC) {
          orderList.add(cb.asc(cb.function("trunc", Path.class, path)));
        } else if (direction == Direction.DESC_TRUNC) {
          orderList.add(cb.desc(cb.function("trunc", Path.class, path)));
        }
      }
      cq.orderBy(orderList);
View Full Code Here

      ArrayList<Order> order = new ArrayList<Order>();
      while (iter.hasNext()) {
        Entry<String, Direction> entry = iter.next();
        Path<?> path = evsr.get(mt.getSingularAttribute(entry.getKey()));
        if (entry.getValue() == Direction.ASC) {
          order.add(cb.asc(path));
        } else if (entry.getValue() == Direction.DESC) {
          order.add(cb.desc(path));
        }
      }
      cq.orderBy(order);
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.