title: How does DISTINCT work when using JPA and Hibernate
body: <p>What column does DISTINCT work with in JPA and is it possible to change it?</p>
  
  <p>Here's an example JPA query using DISTINCT:</p>
  
  <pre><code>select DISTINCT c from Customer c
  </code></pre>
  
  <p>Which doesn't make a lot of sense - what column is the distinct based on? Is it specified on the Entity as an annotation because I couldn't find one?</p>
  
  <p>I would like to specify the column to make the distinction on, something like:</p>
  
  <pre><code>select DISTINCT(c.name) c from Customer c
  </code></pre>
  
  <p>I'm using MySQL and Hibernate.</p>