static inner class
๋ฅผ JPQL
@Query
๋ฅผ ํตํด ์กฐํํ๋ ์ฟผ๋ฆฌ๋ฅผ ์์ฑํ๋๋ฐ ๋ค์๊ณผ ๊ฐ์ ์๋ฌ๋ฅผ ๋ง์ฃผํ๋ค.
@Query("SELECT new woowa.promotion.dto.response.CouponGroupSimpleResponse.CouponGroupSimpleDto("
+ "couponGroup.id, couponGroup.title) FROM CouponGroup couponGroup "
+ "WHERE (:cursor = 0L OR couponGroup.id < :cursor) "
+ "ORDER BY couponGroup.id DESC"
)
org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name ...
...
Caused by: org.springframework.data.repository.query.QueryCreationException:
Could not create query for public abstract java.util.Optional ...
Reason: Validation failed for query for method public abstract java.util.Optional
...
Caused by: java.lang.IllegalArgumentException:
org.hibernate.hql.internal.ast.QuerySyntaxException: Unable to locate class
...
์ฒ์์๋ ๋์๋ฌธ์ ๋ฌธ์ ๋ ์คํ๊ฐ ์๋์ค ์๊ณ ์ฟผ๋ฆฌ๋ฅผ ๋๋น ์ง๊ฒ ๋ดค๋๋ฐ ๋ฌธ์ ๊ฐ ์์๋ค.
์ฐพ์๋ณด๋ inner class
์ ๊ฒฝ์ฐ $
๋ก ํ์ํด์ผ ํ๋ค๊ณ ํ๋ค.
@Query("SELECT new woowa.promotion.dto.response.CouponGroupSimpleResponse$CouponGroupSimpleDto("
// ์๋ต
)
์ฐธ๊ณ ๋ก ์ฟผ๋ฆฌ์ $
ํ์๋ฅผ ์ฌ์ฉํ๊ฒ ๋๋ฉด ๋นจ๊ฐ์ค์ด ๋จ๋๋ฐ ๋ฌด์ํ๋ฉด ๋๋ค.
๊ด๋ จํด์ Jetbrains ์ปค๋ฎค๋ํฐ์ ์ด์๊ฐ ์๋๋ฐ ์์ง ํด๊ฒฐ์ด ์๋ ๊ฒ ๊ฐ๋ค.