我正在尝试使用这样的自定义查询:
@Query("SELECT i " +
"FROM ManagerWorkplace i " +
"WHERE i.managerId = ?1 " +
"AND i.companyId = ?2 " +
"GROUP BY i.zoneId")
List findByManagerIdAndCompanyId(Long managerID, Long companyId);
但是我得到了这个错误:
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column ‘db_oem.managerwor0_.id’ which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
我知道一种通过使用以下方法在MySQL上修复此错误的方法
SET sql_mode=(SELECT REPLACE(@@sql_mode,’ONLY_FULL_GROUP_BY’,”))
,有什么方法可以对JpaRepository做同样的事情吗?