use of javax.persistence.EntityManager in project OpenAttestation by OpenAttestation.
the class TblMleJpaController method getTblMleCount.
public int getTblMleCount() {
EntityManager em = getEntityManager();
try {
CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
Root<TblMle> rt = cq.from(TblMle.class);
cq.select(em.getCriteriaBuilder().count(rt));
Query q = em.createQuery(cq);
return ((Long) q.getSingleResult()).intValue();
} finally {
em.close();
}
}
use of javax.persistence.EntityManager in project OpenAttestation by OpenAttestation.
the class TblMleJpaController method findTblMleByUUID.
public TblMle findTblMleByUUID(String uuid_hex) {
EntityManager em = getEntityManager();
try {
Query query = em.createNamedQuery("TblMle.findByUUID_Hex");
query.setParameter("uuid_hex", uuid_hex);
TblMle tblOem = (TblMle) query.getSingleResult();
return tblOem;
} catch (NoResultException e) {
log.error("NoResultException : MLE with UUID {} not found", uuid_hex);
return null;
} finally {
em.close();
}
}
use of javax.persistence.EntityManager in project OpenAttestation by OpenAttestation.
the class TblMleJpaController method findMleById.
public TblMle findMleById(Integer id) {
EntityManager em = getEntityManager();
try {
Query query = em.createNamedQuery("TblMle.findById");
query.setParameter("id", id);
query.setHint(QueryHints.REFRESH, HintValues.TRUE);
query.setHint(QueryHints.CACHE_USAGE, CacheUsage.DoNotCheckCache);
TblMle mle = (TblMle) query.getSingleResult();
return mle;
} finally {
em.close();
}
}
use of javax.persistence.EntityManager in project OpenAttestation by OpenAttestation.
the class TblModuleManifestJpaController method findByMleId.
public List<TblModuleManifest> findByMleId(Integer mleId) {
EntityManager em = getEntityManager();
try {
Query query = em.createNamedQuery("TblModuleManifest.findByMleId");
query.setParameter("mleId", mleId);
query.setHint(QueryHints.REFRESH, HintValues.TRUE);
query.setHint(QueryHints.CACHE_USAGE, CacheUsage.DoNotCheckCache);
List<TblModuleManifest> tblModuleManifestList = query.getResultList();
return tblModuleManifestList;
} finally {
em.close();
}
}
use of javax.persistence.EntityManager in project OpenAttestation by OpenAttestation.
the class TblModuleManifestJpaController method findTblModuleManifestByHardwareUuid.
public List<TblModuleManifest> findTblModuleManifestByHardwareUuid(String uuid) {
EntityManager em = getEntityManager();
try {
Query query = em.createNamedQuery("TblModuleManifest.findByHardwareUuid");
query.setParameter("uuid_hex", uuid);
List<TblModuleManifest> moduleList = query.getResultList();
return moduleList;
} catch (NoResultException e) {
log.error(String.format("Module information with UUID {} not found in the DB.", uuid));
return null;
} finally {
em.close();
}
}
Aggregations