Search in sources :

Example 1 with MwCertificateX509

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

the class MwCertificateX509JpaController method destroy.

public void destroy(Integer id) throws NonexistentEntityException {
    EntityManager em = getEntityManager();
    try {
        em.getTransaction().begin();
        MwCertificateX509 mwCertificateX509;
        try {
            mwCertificateX509 = em.getReference(MwCertificateX509.class, id);
            mwCertificateX509.getId();
        } catch (EntityNotFoundException enfe) {
            throw new NonexistentEntityException("The mwCertificateX509 with id " + id + " no longer exists.", enfe);
        }
        em.remove(mwCertificateX509);
        em.getTransaction().commit();
    } finally {
        em.close();
    }
}
Also used : EntityManager(javax.persistence.EntityManager) NonexistentEntityException(com.intel.mtwilson.as.controller.exceptions.NonexistentEntityException) MwCertificateX509(com.intel.mtwilson.as.data.MwCertificateX509) EntityNotFoundException(javax.persistence.EntityNotFoundException)

Example 2 with MwCertificateX509

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

the class MwCertificateX509JpaController method findMwCertificateX509Entities.

private List<MwCertificateX509> findMwCertificateX509Entities(boolean all, int maxResults, int firstResult) {
    EntityManager em = getEntityManager();
    try {
        CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
        cq.select(cq.from(MwCertificateX509.class));
        Query q = em.createQuery(cq);
        if (!all) {
            q.setMaxResults(maxResults);
            q.setFirstResult(firstResult);
        }
        return q.getResultList();
    } finally {
        em.close();
    }
}
Also used : EntityManager(javax.persistence.EntityManager) CriteriaQuery(javax.persistence.criteria.CriteriaQuery) Query(javax.persistence.Query) CriteriaQuery(javax.persistence.criteria.CriteriaQuery) MwCertificateX509(com.intel.mtwilson.as.data.MwCertificateX509)

Example 3 with MwCertificateX509

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

the class MwCertificateX509JpaController method getMwCertificateX509Count.

public int getMwCertificateX509Count() {
    EntityManager em = getEntityManager();
    try {
        CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
        Root<MwCertificateX509> rt = cq.from(MwCertificateX509.class);
        cq.select(em.getCriteriaBuilder().count(rt));
        Query q = em.createQuery(cq);
        return ((Long) q.getSingleResult()).intValue();
    } finally {
        em.close();
    }
}
Also used : EntityManager(javax.persistence.EntityManager) CriteriaQuery(javax.persistence.criteria.CriteriaQuery) Query(javax.persistence.Query) CriteriaQuery(javax.persistence.criteria.CriteriaQuery) MwCertificateX509(com.intel.mtwilson.as.data.MwCertificateX509)

Aggregations

MwCertificateX509 (com.intel.mtwilson.as.data.MwCertificateX509)3 EntityManager (javax.persistence.EntityManager)3 Query (javax.persistence.Query)2 CriteriaQuery (javax.persistence.criteria.CriteriaQuery)2 NonexistentEntityException (com.intel.mtwilson.as.controller.exceptions.NonexistentEntityException)1 EntityNotFoundException (javax.persistence.EntityNotFoundException)1