본문 바로가기
Spring

[JPA] Querydsl group by error

by cheery7272 2023. 1. 20.

 

Querydsl로 group By를 사용하여 쿼리문을 작성하였다.

Expression #7 of SELECT list is not in GROUP BY clause and contains nonaggregated column 
'fittingnote.producthit2_.hits' which is not functionally dependent on columns in GROUP BY 
clause; this is incompatible with sql_mode=only_full_group_by

 

정상적으로 동작할거라고 생각했지만 위와 같은 오류가 발생했다.

 

sql_mode의 only_full_group_by 속성이 활성화 되어 있어 현재 group By절과 호환되지 않는다는 문제라고 한다.

 

해결할 수 있는 방법으로는

1. Mysql에서 only_full_group_by를 비활성화 시키는 방법

2. select절 안에 count문을 제외한 컬럼을 group By안에 넣는 방법

2번째 방법을 통해서 해결할 수 있었다.

댓글