Package javax.persistence.criteria

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


        Root<Customer> customer = cquery.from(Customer.class);

        //Get Metamodel from Root
        EntityType<Customer> Customer_ = customer.getModel();

        cquery.where(cb.equal(
                customer.get(Customer_.getSingularAttribute("name", String.class)),
                cb.nullLiteral(String.class)));

        Query q = em.createQuery(cquery);
    }
View Full Code Here


    CriteriaQuery cq = cb.createQuery();
    Root<Book> candidate = cq.from(Book.class);
    candidate.alias("b");
    cq.select(candidate);
    Path titleField = candidate.get("title");
    cq.where(cb.equal(titleField, "Bar Book"));

    Query q = em.createQuery(cq);
    List<Book> books = q.getResultList();
    assertNotNull(books);
    assertEquals(2, books.size());
View Full Code Here

    Root<Book> candidate = cq.from(Book.class);
    candidate.alias("b");
    cq.select(candidate);

    Path titleField = candidate.get("title");
    cq.where(cb.equal(titleField, "Bar Book"));

    Path isbnField = candidate.get("isbn");
    cq.orderBy(cb.desc(isbnField));

    Query q = em.createQuery(cq);
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)));
        cq.select(z);
View Full Code Here

       
        CriteriaBuilder cb = getEntityManager().getCriteriaBuilder();
        CriteriaQuery cq = cb.createQuery();
        Root<Request> z = cq.from(Request.class);
       
        cq.where(cb.and(
                    cb.isNotNull(z.get(Request_.serviceObject)),
                    cb.equal(z.get(Request_.serviceObject), current.getServiceObject()))
                );
               
        cq.orderBy(cb.desc(z.get(Request_.id)));
View Full Code Here

             
       
//        cq.where(cb.and(where, whereCreatedByOrg));   при whereCreatedByOrg == null - NPE 
       
        if(whereCreatedByOrg == null) { // whereCreatedByOrg инициализируется только когда задана орг-ия
            cq.where(where);    
        } else {
            cq.where(cb.and(where, whereCreatedByOrg));    
        }
  
           
View Full Code Here

//        cq.where(cb.and(where, whereCreatedByOrg));   при whereCreatedByOrg == null - NPE 
       
        if(whereCreatedByOrg == null) { // whereCreatedByOrg инициализируется только когда задана орг-ия
            cq.where(where);    
        } else {
            cq.where(cb.and(where, whereCreatedByOrg));    
        }
  
           
        cq.orderBy(cb.desc(z.get(Request_.id)));
        cq.select(z);
View Full Code Here

    public List<UserHD> findAll() {
       
        CriteriaBuilder cb = getEntityManager().getCriteriaBuilder();
        CriteriaQuery cq = cb.createQuery();
        Root<UserHD> z = cq.from(UserHD.class);
        cq.where(cb.isNotNull(z.get(UserHD_.login))); // пустой логин - пользователь "выключен"
        cq.orderBy(cb.asc(z.get(UserHD_.id)));
        cq.select(z);
       
        return getEntityManager().createQuery(cq).getResultList();
       
View Full Code Here

       
        CriteriaBuilder cb = getEntityManager().getCriteriaBuilder();
        CriteriaQuery cq = cb.createQuery();
        Root<UserHD> z = cq.from(UserHD.class);
        Join<UserHD, Role> j = z.join(UserHD_.role);
        cq.where(cb.equal(j.get(Role_.name), RoleEnum.SERVICE));
        cq.orderBy(cb.asc(z.get(UserHD_.name)));
        cq.select(z);
       
        List<UserHD> l = getEntityManager().createQuery(cq).getResultList();
        return l;
View Full Code Here

       
        CriteriaBuilder cb = getEntityManager().getCriteriaBuilder();
        CriteriaQuery cq = cb.createQuery();
        Root<UserHD> z = cq.from(UserHD.class);
        Join<UserHD, Role> j = z.join(UserHD_.role);
        cq.where(cb.equal(j.get(Role_.name), RoleEnum.CUSTOMER));
        cq.orderBy(cb.asc(z.get(UserHD_.name)));
        cq.select(z);
       
        List<UserHD> l = getEntityManager().createQuery(cq).getResultList();
        return l;
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.