Java Reference
In-Depth Information
}
}
public List<Customer> findCustomerEntities() {
return findCustomerEntities(true, -1, -1);
}
public List<Customer> findCustomerEntities(int maxResults,
int firstResult) {
return findCustomerEntities(false, maxResults, firstResult);
}
private List<Customer> findCustomerEntities(boolean all, int
maxResults,
int firstResult) {
EntityManager em = getEntityManager();
try {
CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
cq.select(cq.from(Customer.class));
Query q = em.createQuery(cq);
if (!all) {
q.setMaxResults(maxResults);
q.setFirstResult(firstResult);
}
return q.getResultList();
} finally {
em.close();
}
}
public Customer findCustomer(Long id) {
EntityManager em = getEntityManager();
try {
return em.find(Customer.class, id);
} finally {
em.close();
}
}
public int getCustomerCount() {
EntityManager em = getEntityManager();
try {
CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
Root<Customer> rt = cq.from(Customer.class);
 
Search WWH ::




Custom Search