Search in sources :

Example 1 with CriteriaQuery

use of javax.persistence.criteria.CriteriaQuery in project OpenAttestation by OpenAttestation.

the class TblMleJpaController method getTblMleCount.

public int getTblMleCount() {
    EntityManager em = getEntityManager();
    try {
        CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
        Root<TblMle> rt = cq.from(TblMle.class);
        cq.select(em.getCriteriaBuilder().count(rt));
        Query q = em.createQuery(cq);
        return ((Long) q.getSingleResult()).intValue();
    } finally {
        em.close();
    }
}
Also used : EntityManager(javax.persistence.EntityManager) CriteriaQuery(javax.persistence.criteria.CriteriaQuery) Query(javax.persistence.Query) TblMle(com.intel.mtwilson.as.data.TblMle) CriteriaQuery(javax.persistence.criteria.CriteriaQuery)

Example 2 with CriteriaQuery

use of javax.persistence.criteria.CriteriaQuery in project OpenAttestation by OpenAttestation.

the class TblOsJpaController method findTblOsEntities.

private List<TblOs> findTblOsEntities(boolean all, int maxResults, int firstResult) {
    EntityManager em = getEntityManager();
    try {
        CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
        cq.select(cq.from(TblOs.class));
        Query q = em.createQuery(cq);
        if (!all) {
            q.setMaxResults(maxResults);
            q.setFirstResult(firstResult);
        }
        return q.getResultList();
    } finally {
        em.close();
    }
}
Also used : EntityManager(javax.persistence.EntityManager) CriteriaQuery(javax.persistence.criteria.CriteriaQuery) Query(javax.persistence.Query) CriteriaQuery(javax.persistence.criteria.CriteriaQuery) TblOs(com.intel.mtwilson.as.data.TblOs)

Example 3 with CriteriaQuery

use of javax.persistence.criteria.CriteriaQuery in project OpenAttestation by OpenAttestation.

the class TblPackageNamespaceJpaController method getTblPackageNamespaceCount.

public int getTblPackageNamespaceCount() {
    EntityManager em = getEntityManager();
    try {
        CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
        Root<TblPackageNamespace> rt = cq.from(TblPackageNamespace.class);
        cq.select(em.getCriteriaBuilder().count(rt));
        Query q = em.createQuery(cq);
        return ((Long) q.getSingleResult()).intValue();
    } finally {
        em.close();
    }
}
Also used : EntityManager(javax.persistence.EntityManager) CriteriaQuery(javax.persistence.criteria.CriteriaQuery) Query(javax.persistence.Query) CriteriaQuery(javax.persistence.criteria.CriteriaQuery) TblPackageNamespace(com.intel.mtwilson.as.data.TblPackageNamespace)

Example 4 with CriteriaQuery

use of javax.persistence.criteria.CriteriaQuery in project OpenAttestation by OpenAttestation.

the class TblPcrManifestJpaController method findTblPcrManifestEntities.

private List<TblPcrManifest> findTblPcrManifestEntities(boolean all, int maxResults, int firstResult) {
    EntityManager em = getEntityManager();
    try {
        CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
        cq.select(cq.from(TblPcrManifest.class));
        Query q = em.createQuery(cq);
        if (!all) {
            q.setMaxResults(maxResults);
            q.setFirstResult(firstResult);
        }
        return q.getResultList();
    } finally {
        em.close();
    }
}
Also used : EntityManager(javax.persistence.EntityManager) CriteriaQuery(javax.persistence.criteria.CriteriaQuery) Query(javax.persistence.Query) CriteriaQuery(javax.persistence.criteria.CriteriaQuery) TblPcrManifest(com.intel.mtwilson.as.data.TblPcrManifest)

Example 5 with CriteriaQuery

use of javax.persistence.criteria.CriteriaQuery in project OpenAttestation by OpenAttestation.

the class TblPcrManifestJpaController method getTblPcrManifestCount.

public int getTblPcrManifestCount() {
    EntityManager em = getEntityManager();
    try {
        CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
        Root<TblPcrManifest> rt = cq.from(TblPcrManifest.class);
        cq.select(em.getCriteriaBuilder().count(rt));
        Query q = em.createQuery(cq);
        return ((Long) q.getSingleResult()).intValue();
    } finally {
        em.close();
    }
}
Also used : EntityManager(javax.persistence.EntityManager) CriteriaQuery(javax.persistence.criteria.CriteriaQuery) Query(javax.persistence.Query) CriteriaQuery(javax.persistence.criteria.CriteriaQuery) TblPcrManifest(com.intel.mtwilson.as.data.TblPcrManifest)

Aggregations

CriteriaQuery (javax.persistence.criteria.CriteriaQuery)148 EntityManager (javax.persistence.EntityManager)109 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)105 Query (javax.persistence.Query)104 TypedQuery (javax.persistence.TypedQuery)69 Predicate (javax.persistence.criteria.Predicate)49 EntityTransaction (javax.persistence.EntityTransaction)45 Root (javax.persistence.criteria.Root)33 List (java.util.List)22 Path (javax.persistence.criteria.Path)18 Test (org.testng.annotations.Test)16 UserTransaction (javax.transaction.UserTransaction)15 Person (org.datanucleus.samples.annotations.models.company.Person)15 Manager (org.datanucleus.samples.jpa.query.Manager)14 Item (org.jpwh.model.querying.Item)12 Specification (org.springframework.data.jpa.domain.Specification)12 Test (org.junit.Test)11 ArrayList (java.util.ArrayList)10 Join (javax.persistence.criteria.Join)10 QueryingTest (org.jpwh.test.querying.QueryingTest)9