-
카테고리
-
세부 분야
백엔드
-
해결 여부
미해결
상속 없는 Custom Repository Interface가 어떻게 동작이 가능 한 건가요??
20.08.24 12:57 작성 조회수 189
0
안녕하세요
'스프링 DATA Common2- Interface 정의' 강좌가 이해가 안됩니다
강의내용 예제 처럼 CustomRepository를 만들었고 save() 와 findAll() 메소드에는 구현체가 없는데 어떻게 data가
저장이 되고 찾아 지는건가요?
이전 강좌에서 만는 Repository interface는 JpaRepository 를 extend 받았고, 그 위로 어찌어찌 찾아가다 보니 구현 체인 SimpleJpaRepository 란 놈에서 save()가 구현 되는걸 알았습니다.
근데 아래의 제가 만든 CommentRepsoity 는 상속 받은 interface가 하나도 없는데 됩니다.
Interface 위에 붙은 Annotation (@RepositoryDefinition) 때문에 알아서 내부적으로 save(), findAll() 를
구현 해주는건가요???
package com.example.SpringDataJPATest.repository;
import com.example.SpringDataJPATest.domain.Comment;
import org.springframework.data.repository.Repository;
import org.springframework.data.repository.RepositoryDefinition;
import java.io.Serializable;
import java.util.List;
@RepositoryDefinition(domainClass = Comment.class, idClass = Long.class)
public interface CommentRepository {
Comment save(Comment comment);
List<Comment> findAll();
}
답변을 작성해보세요.
1
답변 1