Package javax.persistence.criteria

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


   
    public void findMapStateRequest(Map<String, StateRequest> map) {
        CriteriaBuilder cb = getEntityManager().getCriteriaBuilder();
        CriteriaQuery cq = cb.createQuery();
        Root<StateRequest> z = cq.from(StateRequest.class);
        cq.select(z);
       
        List<StateRequest>x = em.createQuery(cq).getResultList();
       
        for(StateRequest xx: x) {
            map.put(xx.getId(), xx);
View Full Code Here


            cq.where(cb.and(whereState, cb.or(whereCreatedBy, whereCreatedByOrg)));
        }
       
       
        cq.orderBy(cb.desc(z.get(Request_.id)));
        cq.select(z);

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

        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

        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

       
        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 c from Customer c "
                    + "where c.name='Autowest Toyota'";
       
        CriteriaQuery q = cb.createQuery();
        Root<Customer> customer = q.from(Customer.class);
        q.select(customer)
         .where(cb.equal(
                customer.get(customer_.getSingularAttribute("name", String.class)),
                "Autowest Toyota"));

        assertEquivalence(q, jpql);
View Full Code Here

        Root<Customer> c = q.from(Customer.class);
        SetJoin<Customer, Order> o = c.join(customer_.getSet("orders",
                Order.class));
        ListJoin<Order, LineItem> i = o.join(order_.getList("lineItems",
                LineItem.class));
        q.select(c.get(Customer_.name)).where(
                cb.equal(i.get(lineItem_.getSingularAttribute("product", Product.class))
                    .get(product_.getSingularAttribute("productType", String.class)),
                    "printer"));

        assertEquivalence(q, jpql);
View Full Code Here

   
    public void testTypeExpression() {
        String jpql = "SELECT TYPE(e) FROM Employee e WHERE TYPE(e) <> Exempt";
        CriteriaQuery q = cb.createQuery();
        Root<Employee> emp = q.from(Employee.class);
        q.select(emp.type()).where(cb.notEqual(emp.type(), Exempt.class));

        assertEquivalence(q, jpql);
    }
   
    public void testJoinAndIndexExpression() {
View Full Code Here

                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);
    }
   
    public void testSizeExpressionInProjection() {
View Full Code Here

    public void testEqualWithAttributeAndLiteral() {
        String jpql = "select a from Account a where a.balance=100";

        CriteriaQuery c = cb.createQuery();
        Root<Account> account = c.from(Account.class);
        c.select(account).where(cb.equal(account.get(Account_.balance), 100));

        assertEquivalence(c, jpql);
    }

    public void testEqualWithAttributeAndAttribute() {
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.