title: Spring data jpa - Return map
body: <p>I have a database with various values, all associated with a date. What I wanna do is to return a map with the date and the average of all values associated with the date. Everytime I make a request I get the following response:</p>
  
  <pre><code>{
      "timestamp": 1473327111738,
      "status": 500,
      "error": "Internal Server Error",
      "exception": "org.springframework.dao.IncorrectResultSizeDataAccessException",
      "message": "result returns more than one elements; nested exception is javax.persistence.NonUniqueResultException: result returns more than one elements",
      "path": "/dailyAverage"
  }
  </code></pre>
  
  <p>My code:</p>
  
  <pre><code>@Query("SELECT du.date, avg(du.usage) FROM DataUsageModel du WHERE du.date BETWEEN :start_time AND :end_time GROUP BY day(du.date)")
  Map&lt;String, Double&gt; findDailyAverages(@Param("start_time") LocalDateTime startTime, @Param("end_time") LocalDateTime endTime);
  </code></pre>