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();
}
}
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();
}
}
Aggregations