title: Spring Boot generates invalid MySQL query (only_full_group_by)
body: <p>I'm using Spring Boot 1.5.2 and the following @Query:</p>
  
  <pre><code>@Query(value = "SELECT m FROM Message m WHERE m.from.userId = :myId OR m.to.userId = :myId GROUP BY m.from.userId, m.to.userId ORDER BY m.date DESC")
  List&lt;Message&gt; chatOverview(@Param("myId") final Long myUserId);
  </code></pre>
  
  <p>The intention of the query is to create a chat messenger overview, where you see the last message of each conversation you had. It works fine for me in dev, but in production (newer MySQL database version) I get this error:</p>
  
  <pre><code>java.sql.SQLSyntaxErrorException: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'message0_.message_id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
  </code></pre>
  
  <p>I read in this <a href="https://stackoverflow.com/questions/34115174/error-related-to-only-full-group-by-when-executing-a-query-in-mysql">thread</a> what the reason for this change was, however I couldn't find a way to fix this with JPA / Spring. I cannot change any settings in the production MySQL database and I would like to avoid any upgrading in Spring either. How can I fix my query?</p>