title: Using distinct in Spring data over multiple columns
body: <p>My domain model is like this:</p>
  
  <pre><code>CollectedData {
    String name;
    String description;
    int count;
    int xAxis,
    int yAxis
  }
  </code></pre>
  
  <p>Using Spring data repository query, I would like to retrieve all the unique rows (unique with name, xAxis, yAxis)</p>
  
  <p>I am trying something like this</p>
  
  <pre><code>@Query("select distinct a.name, a.xAxis, a.yAxis from CollectedData a")
  List&lt;CollectedData&gt; findAllDistinctData();
  </code></pre>
  
  <p>So, when I do </p>
  
  <pre><code>List&lt;CollectedData&gt; records= findAllDistinctData();
  for (CollectedData record : records) { //Exception on this line
   }
  </code></pre>
  
  <p>Exception
  [Ljava.lang.Object; cannot be cast to CollectedData.</p>
  
  <p>Is there any other way to write query for this ?</p>