code: @Override
      public Iterator<? extends T> iterator(final long first, final long count) {
          entityManager.getTransaction().begin();
  
          try {
              final CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
              final CriteriaQuery<T> criteria = criteriaBuilder.createQuery(type);
              final Root<T> from = criteria.from(type);
  
              // setup the sort
              final SortParam<String> param = getSort();
  
              if(param == null || param.isAscending()) {
                  LOG.debug("Setting order by to ascending for {}", type.getName());
                  criteria.orderBy(criteriaBuilder.asc(from.get("name")));
              } else {
                  LOG.debug("Setting order by to descending for {}", type.getName());
                  criteria.orderBy(criteriaBuilder.desc(from.get("name")));
              }
  
              return entityManager.createQuery(criteria)
                                  .setFirstResult((int)first)
                                  .setMaxResults((int)count)
                                  .getResultList()
                                  .iterator();
          } finally {
              entityManager.getTransaction().commit();
          }
      }
docs: /*
  Note we cannot use the @Transactional annotation here because it makes
  not serializable: https://code.google.com/p/google-guice/issues/detail?id=12