Notice
Recent Posts
Recent Comments
Link
«   2025/05   »
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 31
Tags
more
Archives
Today
Total
관리 메뉴

blog

[Spring Boot] JPA @Query 본문

Web/SpringBoot

[Spring Boot] JPA @Query

hjkongkong 2022. 3. 23. 20:06

기본 select를 제외하고 실제 쿼리문으로 쿼리를 하려고한다.

1
2
3
@Query(value = "SELECT * FROM MEMBER mem WHERE mem.age = (:age) AND mem.office = (:office)", nativeQuery = true)
public List<member> selectByAgeOffice(@Param(value = "age")int age, @Param(value = "office")String office);
 
cs

memberRepository.java에 추가

1
2
3
4
5
@GetMapping("select")
public List<member> selectByAgeOffice() {
    return memberrepo.selectByAgeOffice(60,"London");
}
 
cs

APIController.java에 추가

 

참고 : https://www.baeldung.com/spring-data-jpa-query


jpa org.springframework.beans.factory.UnsatisfiedDependencyException

@Query를 사용하여 쿼리문을 작성한 뒤 해당 에러가 발생했다.

오류 내용을 읽어보니 쿼리문 구문 문법 오류였다

@Query(value = "SELECT * FROM MEMBER mem WHERE mem.age = (:office) AND mem.office = (:office)",nativeQuery = true)

오타...