0. JpaRepository
JpaRepository는 DB와 연동하여 작업을 수행하는데 필요한 기본적인 CRUD 메서드들을 포함하고 있다. 이전에 배웠던 Mybatis와 비교하자면 mapper XML과 비슷한 역할을 하되, 좀 더 추상적인 형태를 가지면서 간단하게 사용할 수 있는 매퍼라고 할 수 있다.
CRUD에 필요한 기본적인 내용은 미리 준비되어 있으므로 JpaRepository를 상속한 Interface를 생성하면 된다. 여기서 JpaRepository의 제너릭은 <엔티티, 기본 키의 데이터 타입>이므로 그에 맞추어 작성하면 된다.
package com.web.springtest00.data.repository;
import org.springframework.data.jpa.repository.JpaRepository;
import com.web.springtest03.data.entity.Product;
public interface ProductRepository extends JpaRepository<Product, Long>{}
'Java > Spring Boot' 카테고리의 다른 글
[Spring Boot] DAO 생성 (0) | 2023.03.28 |
---|---|
[Spring Boot] DTO 생성 (0) | 2023.03.28 |
[Spring Boot] Entity 생성 (0) | 2023.03.28 |
[Spring Boot] application.properties 설정 (0) | 2023.03.28 |
[Spring Boot] VSCode로 시작하기 (0) | 2023.03.27 |