title: Transform from Pageable.getSort() to List<Order> to sort a query made by Criteria API in a Spring repository custom
body: <p>I've implemented one my custom Spring repository which receives in input a <code>org.springframework.data.domain.Pageable</code> object. This <code>Pageable</code> object has the following sort property (for example): <code>id: DESC,name: ASC</code>.</p>
  
  <p>I need to convert the <code>pageable.getSort()</code> property into a <code>List&lt;Order&gt;</code> in order to set an order for the <code>criteriaQuery.orderBy(List&lt;Order&gt;)</code> method.</p>
  
  <p>In order to retrieve a paged result, I used the <code>new PageImpl</code> passing it the <code>pageable</code> object, but this not manage the ordering.</p>
  
  <pre><code>TypedQuery&lt;Entity&gt; typedQuery = entityManager.createQuery(criteriaQuery);
  typedQuery.setFirstResult(pageable.getOffset());
  typedQuery.setMaxResults(pageable.getPageSize());
  Page&lt;Entity&gt; page = new PageImpl&lt;Entity&gt;(typedQuery.getResultList(), pageable, typedQuery.getMaxResults());
  return page;
  </code></pre>
  
  <p>Any suggests?
  Thanks, Andrea</p>