use of javax.persistence.Query in project OpenAttestation by OpenAttestation.
the class TblPcrManifestJpaController method findPcrManifestById.
public TblPcrManifest findPcrManifestById(Integer id) {
EntityManager em = getEntityManager();
try {
Query query = em.createNamedQuery("TblPcrManifest.findById");
query.setParameter("id", id);
query.setHint(QueryHints.REFRESH, HintValues.TRUE);
query.setHint(QueryHints.CACHE_USAGE, CacheUsage.DoNotCheckCache);
TblPcrManifest manifest = (TblPcrManifest) query.getSingleResult();
return manifest;
} finally {
em.close();
}
}
use of javax.persistence.Query in project OpenAttestation by OpenAttestation.
the class TblSamlAssertionJpaController method getTblSamlAssertionCount.
public int getTblSamlAssertionCount() {
EntityManager em = getEntityManager();
try {
CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
Root<TblSamlAssertion> rt = cq.from(TblSamlAssertion.class);
cq.select(em.getCriteriaBuilder().count(rt));
Query q = em.createQuery(cq);
return ((Long) q.getSingleResult()).intValue();
} finally {
em.close();
}
}
use of javax.persistence.Query in project OpenAttestation by OpenAttestation.
the class TblSamlAssertionJpaController method findListByHostAndExpiry.
public List<TblSamlAssertion> findListByHostAndExpiry(String host) {
//List<TblSamlAssertion> tblSamlAssertionList = null; //Variable was never read after null being assigned.
List<TblSamlAssertion> tblSamlAssertionList;
EntityManager em = getEntityManager();
try {
Query query = em.createNamedQuery("TblSamlAssertion.findByHostAndExpiry");
query.setParameter("now", new Date(System.currentTimeMillis()));
query.setParameter("hostName", host);
tblSamlAssertionList = query.getResultList();
} finally {
em.close();
}
return tblSamlAssertionList;
}
use of javax.persistence.Query in project OpenAttestation by OpenAttestation.
the class TblEventTypeJpaController method findTblEventTypeEntities.
private List<TblEventType> findTblEventTypeEntities(boolean all, int maxResults, int firstResult) {
EntityManager em = getEntityManager();
try {
CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
cq.select(cq.from(TblEventType.class));
Query q = em.createQuery(cq);
if (!all) {
q.setMaxResults(maxResults);
q.setFirstResult(firstResult);
}
return q.getResultList();
} finally {
em.close();
}
}
use of javax.persistence.Query in project OpenAttestation by OpenAttestation.
the class TblHostSpecificManifestJpaController method findByModuleAndHostID.
public TblHostSpecificManifest findByModuleAndHostID(int hostId, int moduleID) {
EntityManager em = getEntityManager();
try {
Query query = em.createNamedQuery("TblHostSpecificManifest.findByModuleAndHostID");
query.setParameter("hostID", hostId);
query.setParameter("Module_Manifest_ID", moduleID);
TblHostSpecificManifest tblHostSpecificManifest = (TblHostSpecificManifest) query.getSingleResult();
return tblHostSpecificManifest;
} catch (NoResultException e) {
log.error("NoResultException: No Host specific manifest for Host [{}]", String.valueOf(hostId));
return null;
} finally {
em.close();
}
}
Aggregations