Using every place the em.createQuery(criteriaQuery).setMaxResults(2).etResultList() where expect one result and interest the number of results.