use of javax.persistence.criteria.CriteriaQuery in project OpenAttestation by OpenAttestation.
the class TblRequestQueueJpaController method findTblRequestQueueEntities.
private List<TblRequestQueue> findTblRequestQueueEntities(boolean all, int maxResults, int firstResult) {
EntityManager em = getEntityManager();
try {
CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
cq.select(cq.from(TblRequestQueue.class));
Query q = em.createQuery(cq);
if (!all) {
q.setMaxResults(maxResults);
q.setFirstResult(firstResult);
}
return q.getResultList();
} finally {
em.close();
}
}
use of javax.persistence.criteria.CriteriaQuery in project OpenAttestation by OpenAttestation.
the class TblRequestQueueJpaController method getTblRequestQueueCount.
public int getTblRequestQueueCount() {
EntityManager em = getEntityManager();
try {
CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
Root<TblRequestQueue> rt = cq.from(TblRequestQueue.class);
cq.select(em.getCriteriaBuilder().count(rt));
Query q = em.createQuery(cq);
return ((Long) q.getSingleResult()).intValue();
} finally {
em.close();
}
}
use of javax.persistence.criteria.CriteriaQuery in project OpenAttestation by OpenAttestation.
the class TblSamlAssertionJpaController method findTblSamlAssertionEntities.
private List<TblSamlAssertion> findTblSamlAssertionEntities(boolean all, int maxResults, int firstResult) {
EntityManager em = getEntityManager();
try {
CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
cq.select(cq.from(TblSamlAssertion.class));
Query q = em.createQuery(cq);
if (!all) {
q.setMaxResults(maxResults);
q.setFirstResult(firstResult);
}
return q.getResultList();
} finally {
em.close();
}
}
use of javax.persistence.criteria.CriteriaQuery in project robo4j by Robo4J.
the class DefaultRepository method findAllByClass.
@SuppressWarnings("unchecked")
@Override
public <T> List<T> findAllByClass(Class<T> clazz) {
EntityManager em = dataSourceContext.getEntityManager(clazz);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery cq = cb.createQuery(clazz);
Root<T> rs = cq.from(clazz);
CriteriaQuery<T> cq2 = cq.select(rs);
TypedQuery<T> tq = em.createQuery(cq2);
return tq.getResultList();
}
use of javax.persistence.criteria.CriteriaQuery in project aries by apache.
the class AbstractSimpleTransactionTest method testSuspendedTx.
@Test
public void testSuspendedTx() {
Message message = new Message();
message.message = "Hello World!";
txControl.required(() -> {
em.persist(message);
assertEquals(Long.valueOf(0), txControl.notSupported(() -> {
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Long> countQuery = cb.createQuery(Long.class);
countQuery.select(cb.count(countQuery.from(Message.class)));
return em.createQuery(countQuery).getSingleResult();
}));
return null;
});
}
Aggregations