Web/JPA
-
JPA (11) - 다형성 쿼리,엔티티 직접 사용,정적쿼리,벌크연산Web/JPA 2024. 1. 12. 14:40
1. 다형성 쿼리 - TYPE > 조회 대상을 특정 자식으로 한정 (ex Item 중에 Book, Movie를 조회하라) select i from Item i where type(i) IN (Book, Movie) > 자바의 타입 캐스팅과 유사하다. > 상속 구조에서 부모 타입을 특정 자식 타입으로 다룰 때 사용 (FROM, WHERE, SELECT에서 사용) select i from Item i where treat(i as Book).author = 'kim' 2. 엔티티 직접 사용 > JPQL에서 엔티티를 직접 사용하면 SQL에서 해당 엔티티 기본 키 값을 사용한다. select count(m.id) from Member m //엔티티 아이디를 사용 select count(m) from Member..
-
JPA 활용 (1) - 프로젝트 환경설정Web/JPA 2024. 1. 4. 14:24
1. spring boot (build.gradle) > java 17버전 > dependencies: spring-data-jpa, thymeleaf, validation,spring-web, h2 > gradle은 의존관계 추가하면, 그 의존관계에 필요한 모든 의존관계 자동으로 끌어온다. > ./gradlew dependencies -configuration complieClasspath를 보면 의존관계 라이브러리 살펴볼 수 있음 * dependencies 추가하면서, version이 없는 것은 , plugins에 작성된 것은 2. H2 데이터 베이스 설치 > jdbc:h2:~/jspshop (최소한번) -> 한번 들어가줘야함 파일 모드로 들어가기 > ~/jpashop.mv.db -> 파일 생성 한번..