Repository是一个空接口,即是一个标记性接口;Repository Bean;@RepositoryDefinition注解,来替代继承Repository接口;// 源码:
public interface Repository<T, ID extends Seriallizable>{
}
// 使用继承的方式
public interface PersonRepository extends Repository<Person, Integer>{
Person getByLastName(String lastName);
}
// 使用注解替代继承
@RepositoryDefinition(domainClass=Person.class, idClass=Integer.class)
public interface PersonRepository{
Person getByLastName(String lastName);
}
Repository接口的子接口CrudRepository:继承Repository,实现了一组CRUD相关的方法;PagingAndSortingRepository:继承CrudRepository,实现了一组分页排序相关的方法;JpaRepository:继承PagingAndSotringRepository,实现一组JPA规范相关的方法;自定义的XxxRepository:可以继承JpaRepository;JpaSpecificationExecutor:不属于Repository体系,实现一组 JPA Criteria 查询相关的方法;参考资料:
原文:https://www.cnblogs.com/linkworld/p/9164331.html