title: How to get count returned by countQuery in Spring Data JPA?
body: <p>I am using both <code>nativeQuery</code> and <code>countQuery</code> in my <code>Repository</code> layer as:</p>
  <pre><code>@Query(value = &quot;select * FROM Person p where p.forename = :forename and p.surname = :surname&quot;,
  countQuery = &quot;SELECT count(*) FROM Person p where p.forename = :forename&quot;,
    nativeQuery = true)
  User findByForenameAndSurname(@Param(&quot;surname&quot;) String lastname,
                               @Param(&quot;forename&quot;) String firstname);
  }
  </code></pre>
  <p>I want integer count returned by this <code>countQuery</code> and I want to use that count to construct <code>PageRequest</code> object which I want to use for <code>nativeQuery</code> to get the <code>Page</code> object. Can I access this count before constructing <code>PageRequest</code> object?
  Is there any way to get the value returned by <code>countQuery</code>?</p>