title: Count query generated by returning Page<> from Repository method crashes on org.hibernate.QueryException: unexpected char: '`'
body: <p>At great peril, I am trying to combine the use of a native query, @SqlResultSetMapper + non-entity POJO (MyDto), and a repository method that takes a Pageable as a param and returns Page. After overcoming a number of hurdles, it's almost working:</p>
  <ul>
  <li>My entity class is called <code>Order</code>, as is the database table</li>
  <li>My DTO class, to which I am mapping the results of the query, is <code>MyDto</code></li>
  <li>My repository is defined as <code>public interface MyRepository extends JpaRepository&lt;Order, Long&gt;</code></li>
  </ul>
  <p>In my repository, if I use:
  <code>List&lt;MyDto&gt; findResults(Pageable page)</code> I get a list of 1 page of results; everything works fine.</p>
  <p>However, if I use:
  <code>Page&lt;MyDto&gt; findResults(Pageable page)</code>, this happens:</p>
  <pre><code> Error occurred while processing the request: org.springframework.dao.InvalidDataAccessApiUsageException: 
  org.hibernate.QueryException: unexpected char: '`' [select count(o) from `order` o ...
  </code></pre>
  <p>(the query continues after &quot;...&quot; and there are no backticks anywhere else in it)</p>
  <p><strong>Returning <code>Page</code> causes Hibernate to generate a query it can't parse
  (but should be able to)</strong></p>
  <p>I don't think it's worth it to supply the @NamedNativeQuery stuff because it works and doesn't impact how returning Page causes this count query to generate. I'm inclined to think this a Hibernate bug, but am hoping there is a work-around.</p>
  <p>How can I fix this? The backticks are <em>necessary</em>, as <code>order</code> is a MySQL keyword, and even if they weren't, I fail to see why it can't parse it (especially <strong>because it generated it</strong>).</p>