Search in sources :

Example 6 with TblRequestQueue

use of com.intel.mtwilson.as.data.TblRequestQueue 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

TblRequestQueue (com.intel.mtwilson.as.data.TblRequestQueue)6 EntityManager (javax.persistence.EntityManager)3 Test (org.junit.Test)3 Query (javax.persistence.Query)2 CriteriaQuery (javax.persistence.criteria.CriteriaQuery)2 NonexistentEntityException (com.intel.mtwilson.as.controller.exceptions.NonexistentEntityException)1 EntityNotFoundException (javax.persistence.EntityNotFoundException)1