스프링 데이터 Common 7. 커스텀 리포지토리 만들기 - KwangtaekJung/inflearn-spring-data-jpa-keesun GitHub Wiki
스프링 데이터 Common: 커스텀 리포지토리
-
쿼리 메소드(쿼리 생성과 쿼리 찾아쓰기)로 해결이 되지 않는 경우 직접 코딩으로 구현 가능.
- 스프링 데이터 리포지토리 인터페이스에 기능 추가.
- 스프링 데이터 리포지토리 기본 기능 덮어쓰기 가능.
- 구현 방법
- 커스텀 리포지토리 인터페이스 정의
- 인터페이스 구현 클래스 만들기 (기본 접미어는 Impl)
- 엔티티 리포지토리에 커스텀 리포지토리 인터페이스 추가
-
기능 추가하기
-
기본 기능 덮어쓰기
-
접미어 설정하기
@SpringBootApplication
@EnableJpaRepositories(repositoryImplementationPostfix = "Default")
public class InflearnSpringDataJpaKeesunApplication {
public static void main(String[] args) {
SpringApplication.run(InflearnSpringDataJpaKeesunApplication.class, args);
}
}