LastName이 아니라 FirstName으로 검색해 볼까?
- 뷰 변경
- 코드 조금 변경
OwnerController 클래스에서 LastName으로 되어있던 getter, setter등을 firstName으로 변경
OwnerRepository 클래스에서 LastName으로 찾던 Query 어노테이션 firstName으로 변경
정확히 일치하는게 아니라 해당 키워드가 들어있는 걸 찾아볼까?
- 쿼리만 변경
@Query("SELECT DISTINCT owner FROM Owner owner left join owner.pets WHERE owner.firstName LIKE %:firstName% ")
Like 뒤에 :firstName%으로 되어 Prefix가 일치해야 검색가능한것을 surfix도 상관없이 일치하면 검색하도록 변경
*주의* :%firstName% (X) -> %:firstName% (O)
Owner에 age 추가
- 모델 변경
- 스키마 변경
- 데이터 변경
- 뷰 변경
Model Class인(Data Class?) Owner 클래스에 Age 및 getter, setter 추가
h2 data.sql에 Insert 쿼리에 Age용 숫자 추가
h2 schema.sql에 age 추가
입력 및 검색등의 View에 Age 추가
https://github.com/devjun63/spring-petclinic/commit/152e7282015301550052af04f65dea2ec9a7b4be
Changed the method of finding the owner by last name to first name · devjun63/spring-petclinic@152e728
Permalink This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository. Browse files Changed the method of finding the owner by last name to first name Loading branch information Showing 5 changed files w
github.com
https://github.com/devjun63/spring-petclinic/commit/d9e39ad1306a27243673d7c41a3ba7db111a31e0
Add age variable to Owner class · devjun63/spring-petclinic@d9e39ad
Permalink This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository. Browse files Add age variable to Owner class Loading branch information Showing 6 changed files with 29 additions and 10 deletions.
github.com
'BackEnd > Spring & Springboot Study' 카테고리의 다른 글
예제로 배우는 스프링 프레임워크 입문 - IOC Container (0) | 2021.11.25 |
---|---|
예제로 배우는 스프링 프레임워크 입문 - IOC (0) | 2021.11.23 |
예제로 배우는 스프링 프레임워크 입문 (0) | 2021.11.23 |
[스프링 웹 개발 기초] - 06. 정적 컨텐츠 (0) | 2021.04.09 |
[스프링 웹 개발 기초] - 05. 정적 컨텐츠 (0) | 2021.04.09 |