SpringData系列二 Repository接口

本节主要介绍Repository接口规范,及其子接口

  1. Repository是一个空接口,即标准接口
  2. 若我们定义的接口继承了Repository,则该接口会被IOC容器识别为一个Repositoty Bean纳入到IOC容器中。进而可以在该接口中定义满足一定规范的方法。
  3. 实际上也可以通过注解的方式定义Repository接口
     PersonRepository.java
  4. Repository的子接口

    

    org.springframework.data.repository.CrudRepository<T, ID> :实现了一组CRUD的方法

    org.springframework.data.repository.PagingAndSortingRepository<T, ID>:实现了一组分页排序相关的方法

    org.springframework.data.jpa.repository.JpaRepository<T, ID>:实现了一组JPA相关规范的方法

    自定义的接口继承JpaRepository 这样的接口就具有通用的数据访问控制层的能力。

原文链接:https://www.cnblogs.com/zhaobingqing/p/6854439.html

原文地址:https://www.cnblogs.com/morganlin/p/12000201.html