美文网首页
springboot之JPA几个常用Repository简单说明

springboot之JPA几个常用Repository简单说明

作者: adced06edef5 | 来源:发表于2019-04-03 11:08 被阅读0次

springboot整合JPA时会用到的几个Repository包含以下几个:
org.springframework.data.repository.Repository<T, ID>
org.springframework.data.repository.CrudRepository<T, ID>
org.springframework.data.repository.PagingAndSortingRepository<T, ID>
org.springframework.data.jpa.repository.JpaRepository<T, ID>
org.springframework.data.repository.query.QueryByExampleExecutor<T>
org.springframework.data.jpa.repository.JpaSpecificationExecutor<T>
其中前4个的继承关系,如图:


image.png

其中CrudRepository主要封装了有些增删改查的操作,PagingAndSortingRepository封装了分页查询操作,QueryByExampleExecutor(QBE)分装了Example查询,JpaSpecificationExecutor封装了以Criteria为基础的查询。一般情况下,在开发过程中继承JpaRepository即可满足基本需求,该类包含了上述类(除JpaSpecificationExecutor)中的全部操作,如需使用Specification查询,则需要额外继承JpaSpecificationExecutor。

相关文章

网友评论

      本文标题:springboot之JPA几个常用Repository简单说明

      本文链接:https://www.haomeiwen.com/subject/oejabqtx.html