@Query로 Dto 조회 시, 내부클래스 접근 방법

19·2023년 6월 4일
0

에러 모음

목록 보기
10/21

@Query로 Dto 조회 시, 내부클래스 접근 방법

@Query로 Dto를 조회하기 위해선 패키지 이름까지 적어주어야 한다.

나의 경우에는 내부 클래스를 사용했는데, 자꾸 오류가 발생했다.

Caused by: org.springframework.data.repository.query.QueryCreationException: Could not create query ...

Caused by: java.lang.IllegalArgumentException: Validation failed for query for method ...

Caused by: java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException: Unable to locate class ...

Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: Unable to locate class ...
  • 이러한 오류가 발생했는데, 결국 내가 @Query로 작성한 쿼리를 생성할 수 없다는 오류

'$'를 붙여서 해결했다

@Query("select new [패키지].[클래스]$[내부 클래스](...) from [조회할 엔티티]")
profile
하나씩 차근차근

0개의 댓글