title: Spring-Data Pageable sort on JPA discriminator field
body: <p>I've got a JPA entity hierarchy with JPA joined inheritance:</p>
  
  <pre><code>@Inheritance(strategy = InheritanceType.JOINED)
  @DiscriminatorColumn(name = "TYPE", discriminatorType = DiscriminatorType.STRING)
  Product
  </code></pre>
  
  <p>and</p>
  
  <pre><code>@Entity
  @Table(name = "product_quiz")
  @DiscriminatorValue("quiz")
  public class QuizProduct extends Product
  </code></pre>
  
  <p>I want to run a spring-data query with QueryByExample and <code>PageRequest</code> like this:</p>
  
  <pre><code>Example&lt;Product&gt; example = ...
  PageRequest pageRequest = ...
  Page&lt;Product&gt; productPage = productRepository.findAll(example, pageRequest);
  </code></pre>
  
  <p>It works fine, except if I set <code>sortField</code> of the <code>pageRequest</code> to be "type" (the <code>@DiscriminatorColumn</code>). </p>
  
  <p>I've tried to:</p>
  
  <ul>
  <li>directly add the type field to the entity. This way the query runs fine, but the persisting operation fails with <code>org.postgresql.util.PSQLException: The column index is out of range: 11, number of columns: 10</code>.</li>
  <li>if I mark this field as <code>@Transient</code>, the persisting works, but the query gives me this exception: <code>Unable to locate Attribute  with the the given name [type] on this ManagedType [...AbstractEntityWithDate]</code> (AbstractEntityWithDate is a <code>@MappedSuperclass</code> of <code>Product</code>, which contains <code>creationDate</code> and <code>modificationDate</code>)</li>
  </ul>
  
  <p>I'm using spring-boot version 1.4.5.RELEASE with the dependency-managed versions of spring-data-jpa(1.10.8.RELEASE) and hibernate(5.0.12.Final).</p>
  
  <p>How can I configure the sorting by discriminator field with <code>Pageable</code>? (I don't want to write custom <code>@Query</code> for this).</p>