일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- 알고리즘트레이닝
- 재테크
- 자바스크립트
- 프로그래머스 알고리즘 공부
- 다독
- 서평
- 투자
- 책알남
- 채권
- 경제
- algorithmStudy
- 돈
- 지혜를가진흑곰
- JavaScript
- 독서
- 책을알려주는남자
- algorithmtraining
- 화장품
- 알고리즘 공부
- 주식
- 백준알고리즘
- 독후감
- 자바
- C++
- Java
- 프로그래밍언어
- 성분
- C
- 알고리즘공부
- algorithmTest
Archives
- Today
- Total
탁월함은 어떻게 나오는가?
[Spring Boot] org.springframework.dao.InvalidDataAccessApiUsageException: For queries with named parameters you need to use provide names for method parameters. 에러 본문
[Snow-ball]server/스프링(Spring)
[Spring Boot] org.springframework.dao.InvalidDataAccessApiUsageException: For queries with named parameters you need to use provide names for method parameters. 에러
Snow-ball 2024. 10. 15. 14:03반응형
org.springframework.dao.InvalidDataAccessApiUsageException: For queries with named parameters you need to use provide names for method parameters. Use @Param for query method parameters, or when on Java 8+ use the javac flag -parameters.; nested exception is java.lang.IllegalStateException: For queries with named parameters you need to use provide names for method parameters. Use @Param for query method parameters, or when on Java 8+ use the javac flag -parameters.
위의 에러는 Spring Data JPA @Query 를 사용할 때 name parameters (이름이 지정된 파라미터)를 올바르게 처리하지 않아서 생기는 문제이다.
Jpa 쿼리에서 :parameterName 형태로 파라미터를 지정하면, 메서드의 파라미터에도 @Param("parameterName")을 명시적으로추가해주면 해결된다.
수정 전:
1
2
|
@Query("SELECT f.idx FROM Firebase f WHERE f.userId = :userId ORDER BY f.idx DESC")
Optional<Long> findFirstByUserIdOrderByIdxDesc(String userId);
|
cs |
수정 후:
1
2
|
@Query("SELECT f.idx FROM Firebase f WHERE f.userId = :userId ORDER BY f.idx DESC")
Optional<Long> findFirstByUserIdOrderByIdxDesc(@Param("userId") String userId);
|
cs |
반응형