title: Retrieve Total Elements from a Page Instance - Spring MVC
body: <p>Utilizing the Spring Framework's <a href="http://docs.spring.io/spring-data/commons/docs/current/api/org/springframework/data/domain/Page.html" rel="nofollow noreferrer"><code>Page</code></a> interface I'm able to retrieve 50 users at a time with the code below:</p>
  
  <pre><code>int page = 0;
  int pageSize = 50;
  Page&lt;User&gt; userPage = userRepo.findByFirstName("Bob", page, pageSize);
  List&lt;User&gt; userList = userPage.getContent();
  </code></pre>
  
  <p>This runs some query in the background to give me my first 50 users in my database. What I want to do is populate my <code>userList</code> <strong><em>without</em></strong> paging so that every is returned from the underlying query - is this possible?</p>
  
  <p>I've tried the <code>hasNext()</code> method on my <code>Page</code> object but it runs in an endless loop</p>
  
  <pre><code>while(userPage.hasNext()){
      logger.info("Next page found");
  }
  </code></pre>
  
  <p>Any ideas?</p>