Closed gringrape closed 1 year ago
petClinic application 실행.
Owner, Pet, Visit
프로젝트 살펴보기에서 하는 일들.
프로젝트 구조
view 의 위치
로그 모드 변경 - application.properties
구현
쿼리를 직접지정하는 방식.
@Query("SELECT DISTINCT owner FROM Owner owner left join owner.pets WHERE owner.firstName LIKE :firstName% ")
@Transactional(readOnly = true)
Page<Owner> findByFirstName(@Param("firstName") String firstName, Pageable pageable);
@Query
annotation -> named parameter https://docs.spring.io/spring-data/jpa/docs/current/reference/html/#jpa.named-parameters
H2 Data Types
Owner table 에 age 정보 추가.
CREATE TABLE owners (
id INTEGER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
first_name VARCHAR(30),
last_name VARCHAR_IGNORECASE(30),
age SMALLINT,
address VARCHAR(255),
city VARCHAR(80),
telephone VARCHAR(20)
);
model
수정 Press ⌥ twice, and then without releasing it, press up or down arrow keys.
See. https://www.jetbrains.com/help/idea/multicursor.html#add-carets-above-or-below-the-current-caret
Owner 조회 화면에 age 추가
URL
: http://localhost:8080/owners/6
handler
:
@GetMapping("/owners/{ownerId}")
public ModelAndView showOwner(@PathVariable("ownerId") int ownerId) {
ModelAndView mav = new ModelAndView("owners/ownerDetails");
Owner owner = this.owners.findById(ownerId);
mav.addObject(owner);
return mav;
}
Owner list age 추가
source: https://github.com/spring-projects/spring-petclinic.git