Search in sources :

Example 41 with CriteriaQuery

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

the class TblPackageNamespaceJpaController method findTblPackageNamespaceEntities.

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

Example 42 with CriteriaQuery

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

the class TblTaLogJpaController method findTblTaLogEntities.

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

Example 43 with CriteriaQuery

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

the class TblTaLogJpaController method getTblTaLogCount.

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

Example 44 with CriteriaQuery

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

the class TblRequestQueueJpaController method findTblRequestQueueEntities.

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

Example 45 with CriteriaQuery

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

the class TblRequestQueueJpaController method getTblRequestQueueCount.

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

Aggregations

CriteriaQuery (javax.persistence.criteria.CriteriaQuery)50 EntityManager (javax.persistence.EntityManager)41 Query (javax.persistence.Query)36 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)12 Test (org.junit.Test)10 Root (javax.persistence.criteria.Root)6 Predicate (javax.persistence.criteria.Predicate)5 List (java.util.List)3 TypedQuery (javax.persistence.TypedQuery)3 AbstractMetamodelSpecificTest (org.hibernate.jpa.test.metamodel.AbstractMetamodelSpecificTest)3 Specification (org.springframework.data.jpa.domain.Specification)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