Search in sources :

Example 11 with TblEventType

use of com.intel.mtwilson.as.data.TblEventType in project OpenAttestation by OpenAttestation.

the class TblEventTypeJpaController method getTblEventTypeCount.

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

Example 12 with TblEventType

use of com.intel.mtwilson.as.data.TblEventType in project OpenAttestation by OpenAttestation.

the class TblEventTypeJpaController method findEventTypeByName.

/**
     * Added By: Sudhir on June 21, 2012
     * 
     * Retrieves the table row having the identity for the event name specified.
     * 
     * @param eventName : Name of the event
     * @return : Result set for the query.
     */
public TblEventType findEventTypeByName(String eventName) {
    EntityManager em = getEntityManager();
    try {
        Query query = em.createNamedQuery("TblEventType.findByName");
        query.setParameter("name", eventName);
        // Nov 14, 2013: Commenting out the below setting for better performance and updating the cacheusage to check cache and then DB            
        //query.setHint(QueryHints.REFRESH, HintValues.TRUE);
        query.setHint(QueryHints.CACHE_USAGE, CacheUsage.CheckCacheThenDatabase);
        TblEventType eventType = (TblEventType) query.getSingleResult();
        return eventType;
    } finally {
        em.close();
    }
}
Also used : EntityManager(javax.persistence.EntityManager) TblEventType(com.intel.mtwilson.as.data.TblEventType) CriteriaQuery(javax.persistence.criteria.CriteriaQuery) Query(javax.persistence.Query)

Aggregations

TblEventType (com.intel.mtwilson.as.data.TblEventType)12 TblModuleManifest (com.intel.mtwilson.as.data.TblModuleManifest)9 EntityManager (javax.persistence.EntityManager)9 IllegalOrphanException (com.intel.mtwilson.as.controller.exceptions.IllegalOrphanException)6 NonexistentEntityException (com.intel.mtwilson.as.controller.exceptions.NonexistentEntityException)6 TblMle (com.intel.mtwilson.as.data.TblMle)6 TblPackageNamespace (com.intel.mtwilson.as.data.TblPackageNamespace)6 ArrayList (java.util.ArrayList)6 TblHostSpecificManifest (com.intel.mtwilson.as.data.TblHostSpecificManifest)5 EntityNotFoundException (javax.persistence.EntityNotFoundException)5 ASDataException (com.intel.mtwilson.as.controller.exceptions.ASDataException)3 NoResultException (javax.persistence.NoResultException)3 Query (javax.persistence.Query)3 CriteriaQuery (javax.persistence.criteria.CriteriaQuery)3 ASException (com.intel.mountwilson.as.common.ASException)1 TblEventTypeJpaController (com.intel.mtwilson.as.controller.TblEventTypeJpaController)1 TblMleJpaController (com.intel.mtwilson.as.controller.TblMleJpaController)1 TblModuleManifestJpaController (com.intel.mtwilson.as.controller.TblModuleManifestJpaController)1 TblPackageNamespaceJpaController (com.intel.mtwilson.as.controller.TblPackageNamespaceJpaController)1 CryptographyException (com.intel.mtwilson.crypto.CryptographyException)1