title: duplicate results when sorting by collection property
body: <p>Repost from <a href="https://jira.spring.io/browse/DATAJPA-744" rel="nofollow noreferrer">here</a></p>
  <p>Given entities and repository:</p>
  <pre><code>@Entity
  public final class Partner {
  
      @Id
      private String id;
  
      @OneToMany(mappedBy = &quot;partner&quot;, fetch = FetchType.LAZY)
      private List&lt;Merchant&gt; merchants;
  
      ...
  }
  
  @Entity
  public final class Merchant {
  
      @Id
      private String id;
  
      @Column
      private String name;
  
      @ManyToOne(fetch = FetchType.LAZY)
      private Partner partner;
  
      ...
  }
  
  public interface PartnerRepository
          extends JpaRepository&lt;Partner, String&gt;, QueryDslPredicateExecutor&lt;Partner&gt; {
  
  }
  </code></pre>
  <p>If there is only one partner having two merchants in the DB then the following code incorrectly returns list with two instances of the same parnter.</p>
  <pre><code>partnerRepository.findAll(new Sort(&quot;merchants.name&quot;));
  </code></pre>
  <p>This is caused internally by the DB join. By creating custom implementation that adds the distinct to the selection the result is correctly the single partner.</p>
  <p>Wouldn't it be correct to do distinct selection per default?</p>