spring-data-jpa Repository的基本知識

來源:互聯網
上載者:User

標籤:訪問   介面   ges   分享   項目   and   java   查詢   開發人員   

1.項目中的Repository對象的使用

 

2.Repository 引入的兩種方式

   繼承和使用註解

3.Repository介面的定義

Repository 介面是 spring Data 的一個核心介面,它不提供任何方法,開發人員需要在自己定義的介面中聲明需要的方法

public interface Repository<T, ID extends Serializable> { } 

 

4.Repository介面的層級關係

 

 

基礎的 Repository 提供了最基本的資料訪問功能,其幾個子介面則擴充了一些功能。它們的繼承關係如下: 
Repository: 僅僅是一個標識,表明任何繼承它的均為倉庫介面類 
(1) CrudRepository: 繼承 Repository,實現了一組 CRUD 相關的方法 
(2)PagingAndSortingRepository: 繼承 CrudRepository,實現了一組分頁排序相關的方法 
(3)JpaRepository: 繼承 PagingAndSortingRepository,實現一組 JPA 規範相關的方法

自訂的 XxxxRepository 需要繼承 JpaRepository,這樣的 XxxxRepository 介面就具備了通用的資料存取控制層的能力。

JpaSpecificationExecutor: 不屬於Repository體系,實現一組 JPA Criteria 查詢相關的方法 。 

 

spring-data-jpa Repository的基本知識

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.