Package javax.persistence.criteria

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


                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

    public List<Form> findFormEntities(int maxResults, int firstResult) {
        return findFormEntities(false, maxResults, firstResult);
    }

    private List<Form> findFormEntities(boolean all, int maxResults, int firstResult) {
        CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
        cq.select(cq.from(Form.class));
        Query q = em.createQuery(cq);
        if (!all) {
            q.setMaxResults(maxResults);
            q.setFirstResult(firstResult);
        }
View Full Code Here

    public Form findForm(Long id) {
        return em.find(Form.class, id);
    }

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

    public List<FormData> findFormDataEntities(int maxResults, int firstResult) {
        return findFormDataEntities(false, maxResults, firstResult);
    }

    private List<FormData> findFormDataEntities(boolean all, int maxResults, int firstResult) {
        CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
        cq.select(cq.from(FormData.class));
        Query q = em.createQuery(cq);
        if (!all) {
            q.setMaxResults(maxResults);
            q.setFirstResult(firstResult);
        }
View Full Code Here

    public FormData findFormData(Long id) {
        return em.find(FormData.class, id);
    }

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

    public List<FormBuilderItemData> findFormDataEntities(int maxResults, int firstResult) {
        return findFormDataEntities(false, maxResults, firstResult);
    }

    private List<FormBuilderItemData> findFormDataEntities(boolean all, int maxResults, int firstResult) {
        CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
        cq.select(cq.from(FormBuilderItemData.class));
        Query q = em.createQuery(cq);
        if (!all) {
            q.setMaxResults(maxResults);
            q.setFirstResult(firstResult);
        }
View Full Code Here

    }

    private List<Tagrates> findTagratesEntities(boolean all, int maxResults, int firstResult) {
        EntityManager em = getEntityManager();
        try {
            CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
            cq.select(cq.from(Tagrates.class));
            Query q = em.createQuery(cq);
            if (!all) {
                q.setMaxResults(maxResults);
                q.setFirstResult(firstResult);
            }
View Full Code Here

    }

    public int getTagratesCount() {
        EntityManager em = getEntityManager();
        try {
            CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
            Root<Tagrates> rt = cq.from(Tagrates.class);
            cq.select(em.getCriteriaBuilder().count(rt));
            Query q = em.createQuery(cq);
            return ((Long) q.getSingleResult()).intValue();
        } finally {
            em.close();
        }
View Full Code Here

    }

    private List<Tag> findTagEntities(boolean all, int maxResults, int firstResult) {
        EntityManager em = getEntityManager();
        try {
            CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
            cq.select(cq.from(Tag.class));
            Query q = em.createQuery(cq);
            if (!all) {
                q.setMaxResults(maxResults);
                q.setFirstResult(firstResult);
            }
View Full Code Here

TOP

Related Classes of javax.persistence.criteria.CriteriaQuery

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.