use of com.intel.mtwilson.as.data.MwKeystore in project OpenAttestation by OpenAttestation.
the class MwKeystoreJpaController method findMwKeystoreByName.
/**
*
* @param name
* @return the named MwKeystore, or null if it was not found
*/
public MwKeystore findMwKeystoreByName(String name) {
//HashMap<String,Object> parameters = new HashMap<String,Object>();
//parameters.put("name", name);
//List<MwKeystore> list = searchByNamedQuery("MwKeystore.findByName", parameters);
//if( list.isEmpty() ) {
// return null;
//}
//return list.get(0);
MwKeystore mwKeystoreObj = null;
EntityManager em = getEntityManager();
Query query = em.createNamedQuery("MwKeystore.findByName");
query.setParameter("name", name);
query.setHint(QueryHints.REFRESH, HintValues.TRUE);
query.setHint(QueryHints.CACHE_USAGE, CacheUsage.DoNotCheckCache);
try {
mwKeystoreObj = (MwKeystore) query.getSingleResult();
} catch (javax.persistence.NoResultException e) {
mwKeystoreObj = null;
}
return mwKeystoreObj;
}
use of com.intel.mtwilson.as.data.MwKeystore in project OpenAttestation by OpenAttestation.
the class MwKeystoreJpaController method getMwKeystoreCount.
public int getMwKeystoreCount() {
EntityManager em = getEntityManager();
try {
CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
Root<MwKeystore> rt = cq.from(MwKeystore.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.MwKeystore in project OpenAttestation by OpenAttestation.
the class MwKeystoreJpaController method findMwKeystoreEntities.
private List<MwKeystore> findMwKeystoreEntities(boolean all, int maxResults, int firstResult) {
EntityManager em = getEntityManager();
try {
CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
cq.select(cq.from(MwKeystore.class));
Query q = em.createQuery(cq);
if (!all) {
q.setMaxResults(maxResults);
q.setFirstResult(firstResult);
}
return q.getResultList();
} finally {
em.close();
}
}
use of com.intel.mtwilson.as.data.MwKeystore in project OpenAttestation by OpenAttestation.
the class MwKeystoreJpaController method destroy.
public void destroy(Integer id) throws NonexistentEntityException {
EntityManager em = getEntityManager();
try {
em.getTransaction().begin();
MwKeystore mwKeystore;
try {
mwKeystore = em.getReference(MwKeystore.class, id);
mwKeystore.getId();
} catch (EntityNotFoundException enfe) {
throw new NonexistentEntityException("The mwKeystore with id " + id + " no longer exists.", enfe);
}
em.remove(mwKeystore);
em.getTransaction().commit();
} finally {
em.close();
}
}
Aggregations