Package javax.persistence.criteria

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


            LOGGER.debug("Loading Questions in the Database");
            // TODO: RAGE-24 - Migrate to the QuestionDAO class
            CriteriaBuilder cb = em.getCriteriaBuilder();
            CriteriaQuery<Question> cq = cb.createQuery(Question.class);
            Root<Question> questionRoot = cq.from(Question.class);
            cq.orderBy(cb.asc(questionRoot.get("name")));
            TypedQuery<Question> questionQuery = em.createQuery(cq);
            try
            {
                modQuestionList.removeAll();
                List<Question> questions = questionQuery.getResultList();
View Full Code Here


            criteria = cb.and(criteria, cb.equal(sectionRoot.get("instructor").get("firstName"),
                    instructor.getFirstName()));
            criteria = cb.and(criteria, cb.equal(sectionRoot.get("instructor").get("lastName"),
                    instructor.getLastName()));
            cq.where(criteria);
            cq.orderBy(cb.asc(sectionRoot.get("name")));
            TypedQuery<Section> sectionQuery = em.createQuery(cq);

            sectionResults = sectionQuery.getResultList();
            LOGGER.debug("(getSectionsForCourseAndInstructor) # Sections Found: "
                    + sectionResults.size());
View Full Code Here

             * ordered by Question name
             */
            CriteriaBuilder cb = em.getCriteriaBuilder();
            CriteriaQuery<Question> cq = cb.createQuery(Question.class);
            Root<Question> questionRoot = cq.from(Question.class);
            cq.orderBy(cb.asc(questionRoot.get("name")));
            TypedQuery<Question> nameQuery = em.createQuery(cq);
            tx.begin();
            List<Question> availQuestions = nameQuery.getResultList();
            tx.commit();

View Full Code Here

                {
                    CriteriaBuilder cb = em.getCriteriaBuilder();
                    CriteriaQuery<Course> cq = cb.createQuery(Course.class);
                    Root<Course> courseRoot = cq.from(Course.class);
                    cq.select(courseRoot);
                    cq.orderBy(cb.asc(courseRoot.get("name")));
                    TypedQuery<Course> query = em.createQuery(cq);
                    LOGGER.debug("Query Created");
                    List<Course> courseList = query.getResultList();
                    LOGGER.debug("Courses Found: " + courseList.size());
                    for (int i = 0; i < courseList.size(); i++)
View Full Code Here

        {
            CriteriaBuilder cb = em.getCriteriaBuilder();
            CriteriaQuery<Section> cq = cb.createQuery(Section.class);
            Root<Section> sectionRoot = cq.from(Section.class);
            cq.where(cb.equal(sectionRoot.get("course").get("name"), course.getName()));
            cq.orderBy(cb.asc(sectionRoot.get("name")));
            TypedQuery<Section> sectionQuery = em.createQuery(cq);

            sectionResults = sectionQuery.getResultList();
            LOGGER.debug("(getSectionsForCourse) # Sections Found: "
                    + sectionResults.size());
View Full Code Here

        } else
        {
            CriteriaBuilder cb = entityManager.getCriteriaBuilder();
            CriteriaQuery<Course> cq = cb.createQuery(Course.class);
            Root<Course> courseRoot = cq.from(Course.class);
            cq.orderBy(cb.asc(courseRoot.get("name")));
            TypedQuery<Course> courseQuery = entityManager.createQuery(cq);
            return courseQuery.getResultList();
        }

View Full Code Here

        {
            List<Category> categoryList;
            CriteriaBuilder cb = em.getCriteriaBuilder();
            CriteriaQuery<Category> cq = cb.createQuery(Category.class);
            Root<Category> categoryRoot = cq.from(Category.class);
            cq.orderBy(cb.asc(categoryRoot.get("name")));

            TypedQuery<Category> categoryQuery = em.createQuery(cq);
            categoryList = categoryQuery.getResultList();
            return categoryList;
        }
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<LdapConfig> c = cq.from(LdapConfig.class);
      Predicate condition = cb.equal(c.get("deleted"), false);
      cq.where(condition);
      cq.distinct(asc);
      if (asc) {
        cq.orderBy(cb.asc(c.get(orderby)));
      } else {
        cq.orderBy(cb.desc(c.get(orderby)));
      }
      TypedQuery<LdapConfig> q = em.createQuery(cq);
      q.setFirstResult(start);
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.