[Spring/JPA] Unable to locate class ์—๋Ÿฌ

Jinnyยท2023๋…„ 12์›” 8์ผ
2

Spring

๋ชฉ๋ก ๋ณด๊ธฐ
9/10
post-custom-banner

๐Ÿ’ฃ Trouble Shooting

์ƒํ™ฉ

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 ์ปค๋ฎค๋‹ˆํ‹ฐ์— ์ด์Šˆ๊ฐ€ ์žˆ๋Š”๋ฐ ์•„์ง ํ•ด๊ฒฐ์ด ์•ˆ๋œ ๊ฒƒ ๊ฐ™๋‹ค.




๐Ÿ”— ์ฐธ๊ณ  ๋งํฌ

profile
๋ธ”๋กœ๊ทธ ์ด์‚ฌ๊ฐ”์–ด์š”. https://jinny-l.tistory.com/
post-custom-banner

0๊ฐœ์˜ ๋Œ“๊ธ€