Search in sources :

Example 26 with CriteriaQuery

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

the class TblHostSpecificManifestJpaController method findTblHostSpecificManifestEntities.

private List<TblHostSpecificManifest> findTblHostSpecificManifestEntities(boolean all, int maxResults, int firstResult) {
    EntityManager em = getEntityManager();
    try {
        CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
        cq.select(cq.from(TblHostSpecificManifest.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) TblHostSpecificManifest(com.intel.mtwilson.as.data.TblHostSpecificManifest) CriteriaQuery(javax.persistence.criteria.CriteriaQuery)

Example 27 with CriteriaQuery

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

the class TblHostSpecificManifestJpaController method getTblHostSpecificManifestCount.

public int getTblHostSpecificManifestCount() {
    EntityManager em = getEntityManager();
    try {
        CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
        Root<TblHostSpecificManifest> rt = cq.from(TblHostSpecificManifest.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) TblHostSpecificManifest(com.intel.mtwilson.as.data.TblHostSpecificManifest) CriteriaQuery(javax.persistence.criteria.CriteriaQuery)

Example 28 with CriteriaQuery

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

the class TblLocationPcrJpaController method findTblLocationPcrEntities.

private List<TblLocationPcr> findTblLocationPcrEntities(boolean all, int maxResults, int firstResult) {
    EntityManager em = getEntityManager();
    try {
        CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
        cq.select(cq.from(TblLocationPcr.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) TblLocationPcr(com.intel.mtwilson.as.data.TblLocationPcr)

Example 29 with CriteriaQuery

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

the class MwCertificateX509JpaController method findMwCertificateX509Entities.

private List<MwCertificateX509> findMwCertificateX509Entities(boolean all, int maxResults, int firstResult) {
    EntityManager em = getEntityManager();
    try {
        CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
        cq.select(cq.from(MwCertificateX509.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) MwCertificateX509(com.intel.mtwilson.as.data.MwCertificateX509)

Example 30 with CriteriaQuery

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

the class MwCertificateX509JpaController method getMwCertificateX509Count.

public int getMwCertificateX509Count() {
    EntityManager em = getEntityManager();
    try {
        CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
        Root<MwCertificateX509> rt = cq.from(MwCertificateX509.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) MwCertificateX509(com.intel.mtwilson.as.data.MwCertificateX509)

Aggregations

CriteriaQuery (javax.persistence.criteria.CriteriaQuery)47 EntityManager (javax.persistence.EntityManager)41 Query (javax.persistence.Query)36 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)9 Test (org.junit.Test)9 List (java.util.List)3 TypedQuery (javax.persistence.TypedQuery)3 Root (javax.persistence.criteria.Root)3 AbstractMetamodelSpecificTest (org.hibernate.jpa.test.metamodel.AbstractMetamodelSpecificTest)3 MwAssetTagCertificate (com.intel.mtwilson.as.data.MwAssetTagCertificate)2 MwCertificateX509 (com.intel.mtwilson.as.data.MwCertificateX509)2 MwKeystore (com.intel.mtwilson.as.data.MwKeystore)2 MwMleSource (com.intel.mtwilson.as.data.MwMleSource)2 TblEventType (com.intel.mtwilson.as.data.TblEventType)2 TblHostSpecificManifest (com.intel.mtwilson.as.data.TblHostSpecificManifest)2 TblHosts (com.intel.mtwilson.as.data.TblHosts)2 TblLocationPcr (com.intel.mtwilson.as.data.TblLocationPcr)2 TblMle (com.intel.mtwilson.as.data.TblMle)2 TblModuleManifest (com.intel.mtwilson.as.data.TblModuleManifest)2 TblModuleManifestLog (com.intel.mtwilson.as.data.TblModuleManifestLog)2