Search in sources :

Example 6 with TblLocationPcr

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

the class TblLocationPcrJpaController method findTblLocationPcrByPcrValueEx.

public TblLocationPcr findTblLocationPcrByPcrValueEx(String pcrValue) {
    EntityManager em = getEntityManager();
    try {
        Query query = em.createNamedQuery("TblLocationPcr.findByPcrValue");
        query.setParameter("pcrValue", pcrValue);
        query.setHint(QueryHints.REFRESH, HintValues.TRUE);
        query.setHint(QueryHints.CACHE_USAGE, CacheUsage.DoNotCheckCache);
        try {
            TblLocationPcr locationPcr = (TblLocationPcr) query.getSingleResult();
            return locationPcr;
        } catch (NoResultException e) {
            log.info("NoResultException: Location does not exist for pcr value {} ", pcrValue);
            return null;
        }
    } finally {
        em.close();
    }
}
Also used : EntityManager(javax.persistence.EntityManager) CriteriaQuery(javax.persistence.criteria.CriteriaQuery) Query(javax.persistence.Query) TblLocationPcr(com.intel.mtwilson.as.data.TblLocationPcr) NoResultException(javax.persistence.NoResultException)

Aggregations

TblLocationPcr (com.intel.mtwilson.as.data.TblLocationPcr)6 EntityManager (javax.persistence.EntityManager)5 Query (javax.persistence.Query)4 CriteriaQuery (javax.persistence.criteria.CriteriaQuery)4 NoResultException (javax.persistence.NoResultException)2 ASException (com.intel.mountwilson.as.common.ASException)1 TblLocationPcrJpaController (com.intel.mtwilson.as.controller.TblLocationPcrJpaController)1 NonexistentEntityException (com.intel.mtwilson.as.controller.exceptions.NonexistentEntityException)1 CryptographyException (com.intel.mtwilson.crypto.CryptographyException)1 IOException (java.io.IOException)1 UnknownHostException (java.net.UnknownHostException)1 EntityNotFoundException (javax.persistence.EntityNotFoundException)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 ConfigurationException (org.apache.commons.configuration.ConfigurationException)1