【发布时间】:2020-05-26 16:52:27
【问题描述】:
我有这个 JPA 查询:
@Query("select count(de) from DeviceEvent de left join de.deviceMessage dm where dm.level = AlarmLevelEnum.HIGH order by de.dateReceived desc ")
int numDeviceEventsWithAlarm ();
但是当我运行查询时,我收到了这条消息:
2020-05-26 18:46 [http-nio-5678-exec-1] WARN o.h.e.jdbc.spi.SqlExceptionHelper - SQL Error: 90016, SQLState: 90016
2020-05-26 18:46 [http-nio-5678-exec-1] ERROR o.h.e.jdbc.spi.SqlExceptionHelper - La columna "DEVICEEVEN0_.DATE_RECEIVED" debe estar incluida en la lista de GROUP BY
Column "DEVICEEVEN0_.DATE_RECEIVED" must be in the GROUP BY list; SQL statement:
select count(deviceeven0_.id) as col_0_0_ from t_device_event deviceeven0_ left outer join t_device_message devicemess1_ on deviceeven0_.device_message_id=devicemess1_.id where devicemess1_.level=2 order by deviceeven0_.date_received desc [90016-200]
【问题讨论】:
标签: mysql hibernate spring-boot jpa spring-data-jpa