Package javax.persistence.criteria

Examples of javax.persistence.criteria.CriteriaQuery.where()


            return null;
        }
        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


       
       
//        cq.where(cb.and(whereState, cb.or(whereCreatedBy, whereCreatedByOrg))); // у заказчика не задана орг-ия - whereCreatedByOrg - NPE

        if(whereCreatedByOrg == null) {
            cq.where(cb.and(whereState, whereCreatedBy));
        } else {
            cq.where(cb.and(whereState, cb.or(whereCreatedBy, whereCreatedByOrg)));
        }
       
       
View Full Code Here

//        cq.where(cb.and(whereState, cb.or(whereCreatedBy, whereCreatedByOrg))); // у заказчика не задана орг-ия - whereCreatedByOrg - NPE

        if(whereCreatedByOrg == null) {
            cq.where(cb.and(whereState, whereCreatedBy));
        } else {
            cq.where(cb.and(whereState, cb.or(whereCreatedBy, whereCreatedByOrg)));
        }
       
       
        cq.orderBy(cb.desc(z.get(Request_.id)));
        cq.select(z);
View Full Code Here

        }
       
       
       
        if(wherePerfomer == null) {
            cq.where(whereState);
        } else {
            cq.where(cb.and(whereState, wherePerfomer));
        }

        cq.orderBy(cb.desc(z.get(Request_.id)));
View Full Code Here

            return null;
        }
        CriteriaBuilder cb = getEntityManager().getCriteriaBuilder();
        CriteriaQuery cq = cb.createQuery();
        Root<HistoryRequest> h = cq.from(HistoryRequest.class);
        cq.where(cb.equal(h.get(HistoryRequest_.request), request));
        cq.orderBy(cb.desc(h.get(HistoryRequest_.modifiedDate)));
       
        cq.select(h);

        return em.createQuery(cq).getResultList();
View Full Code Here

    public List<ServiceObject> findServiceObject(UserHD curUser) {
        CriteriaBuilder cb = getEntityManager().getCriteriaBuilder();
        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

    public List<FileHD> findByRequest(Request request) {
       
        CriteriaBuilder cb = getEntityManager().getCriteriaBuilder();
        CriteriaQuery cq = cb.createQuery();
        Root<FileHD> z = cq.from(FileHD.class);
        cq.where(cb.equal(z.get(FileHD_.request), request));
        cq.select(z);
        return getEntityManager().createQuery(cq).getResultList();
       
    }
   
View Full Code Here

        String jpql = "SELECT d FROM Department d LEFT JOIN FETCH d.employees "
                + "WHERE d.deptNo = 1";
        CriteriaQuery q = cb.createQuery();
        Root<Department> d = q.from(Department.class);
        d.fetch(department_.getSet("employees", Employee.class), JoinType.LEFT);
        q.where(
                cb.equal(d.get(department_
                        .getSingularAttribute("deptNo", Integer.class)), 1)).select(d);

        assertEquivalence(q, jpql);
    }
View Full Code Here

        Root<Order> o = q.from(Order.class);
        Join<Order, LineItem> i = o.join(order_.getList("lineItems",
                LineItem.class));
        Join<Order, Customer> c = o.join(order_.getSingularAttribute("customer",
                Customer.class));
        q.where(cb.equal(c.get(customer_.getSingularAttribute("lastName", String.class)), "Smith"),
                cb.equal(c.get(customer_.getSingularAttribute("firstName", String.class)), "John"));
        q.select(cb.sum(i.get(lineItem_.getSingularAttribute("price", Double.class))));

        assertEquivalence(q, jpql);
    }
View Full Code Here

        String jpql = "SELECT SIZE(d.employees) FROM Department d "
         + "WHERE d.name = 'Sales'";
       
        CriteriaQuery q = cb.createQuery();
        Root<Department> d = q.from(Department.class);
        q.where(cb.equal(
                d.get(department_.getSingularAttribute("name", String.class)),
                "Sales"));
        SetAttribute<Department, Employee> employees =
            department_.getDeclaredSet("employees", Employee.class);
        q.select(cb.size(d.get(employees)));
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.