Package javax.persistence.criteria

Examples of javax.persistence.criteria.Order


            for (SortField sortField : sortFields) {
                String propertyName = (String) sortField.getSortBy().getValue(facesContext.getELContext());

                Path<Object> expression = root.get(propertyName);

                Order jpaOrder;
                SortOrder sortOrder = sortField.getSortOrder();
                if (sortOrder == SortOrder.ascending) {
                    jpaOrder = criteriaBuilder.asc(expression);
                } else if (sortOrder == SortOrder.descending) {
                    jpaOrder = criteriaBuilder.desc(expression);
View Full Code Here


            for (SortField sortField : sortFields) {
                String propertyName = (String) sortField.getSortBy().getValue(facesContext.getELContext());

                Path<Object> expression = root.get(propertyName);

                Order jpaOrder;
                SortOrder sortOrder = sortField.getSortOrder();
                if (sortOrder == SortOrder.ascending) {
                    jpaOrder = criteriaBuilder.asc(expression);
                } else if (sortOrder == SortOrder.descending) {
                    jpaOrder = criteriaBuilder.desc(expression);
View Full Code Here

            for (SortField sortField : sortFields) {
                String propertyName = (String) sortField.getSortBy().getValue(facesContext.getELContext());

                Path<Object> expression = root.get(propertyName);

                Order jpaOrder;
                SortOrder sortOrder = sortField.getSortOrder();
                if (sortOrder == SortOrder.ascending) {
                    jpaOrder = criteriaBuilder.asc(expression);
                } else if (sortOrder == SortOrder.descending) {
                    jpaOrder = criteriaBuilder.desc(expression);
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

        Root<SearchRequest> root = query.from(SearchRequest.class);

        final Predicate predicate = spec.toPredicate(root, query, cb);
        Path<T> path = groupingPath.getPath(root);

        final Order order;
        switch (direction) {
            case DESC:
                order = cb.desc(path);
                break;
            case ASC:
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

               
                ///////////////String propertyName = (String) sortField.getSortBy().getValue(facesContext.getELContext());
               
                Path<Object> expression = root.get(propertyName);
               
                Order jpaOrder;
                SortOrder sortOrder = sortField.getSortOrder();
                if (sortOrder == SortOrder.ascending) {
                    jpaOrder = criteriaBuilder.asc(expression);
                } else if (sortOrder == SortOrder.descending) {
                    jpaOrder = criteriaBuilder.desc(expression);
View Full Code Here

    Filter filter = new Filter();
    filter.addSortField(mock(SortField.class));
    filter.addSortField(mock(SortField.class));
    CriteriaBuilder builder = mock(CriteriaBuilder.class);
    Root root = mock(Root.class);
    Order order1 = mock(Order.class);
    Order order2 = mock(Order.class);
    when(filter.getSortFields().get(0).getOrder(builder, root)).thenReturn(order1);
    when(filter.getSortFields().get(1).getOrder(builder, root)).thenReturn(order2);
    CriteriaQuery query = mock(CriteriaQuery.class);
    filter.constructQuery(builder, query, root);
    verify(query).orderBy(Arrays.asList(order1, order2));
View Full Code Here

TOP

Related Classes of javax.persistence.criteria.Order

Copyright © 2018 www.massapicom. 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.