Exemplo n.º 1
0
 public List<T> find(SearchCriteria sc, int firstRow, int maxResults) {
   Query q = getEntityManager().createQuery(sc.createQuery());
   Map<String, Object> parameters = sc.getParameters();
   for (String parameterName : parameters.keySet()) {
     q.setParameter(parameterName, parameters.get(parameterName));
   }
   q.setFirstResult(firstRow);
   q.setMaxResults(maxResults);
   return q.getResultList();
 }
Exemplo n.º 2
0
 public int count(SearchCriteria sc) {
   Query q = getEntityManager().createQuery(sc.createCountQuery());
   Map<String, Object> parameters = sc.getParameters();
   for (String parameterName : parameters.keySet()) {
     q.setParameter(parameterName, parameters.get(parameterName));
   }
   Long count = (Long) q.getSingleResult();
   if (count != null) {
     return count.intValue();
   }
   return 0;
 }