Examples of CriteriaQuery


Examples of javax.persistence.criteria.CriteriaQuery

    }

    @GET
    public List<Snapshot> all() {
        CriteriaBuilder cb = this.em.getCriteriaBuilder();
        CriteriaQuery q = cb.createQuery();
        CriteriaQuery<Snapshot> select = q.select(q.from(Snapshot.class));
        return this.em.createQuery(select)
                .getResultList();

    }
View Full Code Here

Examples of javax.persistence.criteria.CriteriaQuery

    public Student findStudent(int id) {
        return em.find(Student.class, id);
    }

    public List<Student> findAllStudent() {
        CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
        cq.select(cq.from(Student.class));
        return em.createQuery(cq).getResultList();
    }
View Full Code Here

Examples of javax.persistence.criteria.CriteriaQuery

        cq.select(cq.from(Student.class));
        return em.createQuery(cq).getResultList();
    }

    public int countStudent() {
        CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
        Root<Student> rt = cq.from(Student.class);
        cq.select(em.getCriteriaBuilder().count(rt));
        Query q = em.createQuery(cq);
        return ((Long) q.getSingleResult()).intValue();
    }
View Full Code Here

Examples of javax.persistence.criteria.CriteriaQuery

        }
        return result;
    }

    public List<Course> findAllCourse() {
        CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
        cq.select(cq.from(Course.class));
        return em.createQuery(cq).getResultList();
    }
View Full Code Here

Examples of javax.persistence.criteria.CriteriaQuery

    public Student findStudent(int id) {
        return em.find(Student.class, id);
    }

    public List<Student> findAllStudent() {
        CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
        cq.select(cq.from(Student.class));
        return em.createQuery(cq).getResultList();
    }
View Full Code Here

Examples of javax.persistence.criteria.CriteriaQuery

        cq.select(cq.from(Student.class));
        return em.createQuery(cq).getResultList();
    }

    public int countStudent() {
        CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
        Root<Student> rt = cq.from(Student.class);
        cq.select(em.getCriteriaBuilder().count(rt));
        Query q = em.createQuery(cq);
        return ((Long) q.getSingleResult()).intValue();
    }
View Full Code Here

Examples of javax.persistence.criteria.CriteriaQuery

        }
        return result;
    }

    public List<Course> findAllCourse() {
        CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
        cq.select(cq.from(Course.class));
        return em.createQuery(cq).getResultList();
    }
View Full Code Here

Examples of javax.persistence.criteria.CriteriaQuery

        em.persist(log);
    }

    public int count() {
        CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
        Root<Log> rt = cq.from(Log.class);
        cq.select(em.getCriteriaBuilder().count(rt));
        Query q = em.createQuery(cq);
//        System.out.println("in LogSessionBean.java, the count res is:"+((Long) q.getSingleResult()).intValue());
       return ((Long) q.getSingleResult()).intValue();
    }
View Full Code Here

Examples of javax.persistence.criteria.CriteriaQuery

    }

    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);
    }
View Full Code Here

Examples of javax.persistence.criteria.CriteriaQuery

                cb.isTrue(cb.disjunction())));
        em.createQuery(c).getResultList();
    }
   
    public void testDefaultProjectionWithUntypedResult() {
        CriteriaQuery cquery = cb.createQuery();
        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
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.