Community
Participate
Working Groups
Found whilst investigating: https://bugs.eclipse.org/bugs/show_bug.cgi?id=362804 (Need to file a separate bug, as the feature fix needs to be tracked and fixed independently) Similar to 362804, setMaxResults can be incorrect / fail on subsequent calls, if invoked again on the same query with a different value. Steps to Reproduce: 1. Create a JPQL Query using EntityManager.createQuery() 2. call setMaxResults(5) 3. execute the query using getResultList(). 4. call setMaxResults(Integer.MAX_VALUE) 5. execute the query again using getResultList() => maxResults of 5 is still used Code: EntityManager em = createEntityManager(); clearCache(); Query query = em.createQuery("SELECT e FROM Employee e"); assertEquals("Query's maxResults should be Integer.MAX_VALUE", Integer.MAX_VALUE, query.getMaxResults()); List controlList = query.getResultList(); List shortenedResults = query.setMaxResults(5).getResultList(); assertEquals("Full list should be shorter than the control results list", 5, shortenedResults.size()); query.setMaxResults(Integer.MAX_VALUE); assertEquals("Query's max results should have been reset", Integer.MAX_VALUE, query.getMaxResults()); List fullResults = query.getResultList(); assertEquals("Full list should be the same as the control results list", controlList.size(), fullResults.size());
Created attachment 230531 [details] Proposed fix & test
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink