JPA 存储库概念是一个通用概念还是由 Spring 框架创造的?
JPA repository concept a general concept or coined by Spring framework?
我正在学习 Spring Data JPA,我遇到了术语“JPA 存储库”(具体来说 Spring数据 JPA 存储库)。我想了解术语“JPA 存储库”是一个一般概念(如 JPA - 标准规范)还是由 Spring 数据项目?
在这种情况下,"repository" 到底是什么意思?
What exactly does "repository" in this context means?
Repository is one of the patterns introduced in Patterns of Enterprise Application Architecture(马丁·福勒,2002 年)。在书中,Repository定义为:
Mediates between the domain and data mapping layers using a
collection-like interface for accessing domain objects
A system with a complex domain model often benefits from a layer, such as the one provided by Data Mapper, that isolates domain
objects from details of the database access code. In such systems it
can be worthwhile to build another layer of abstraction over the
mapping layer where query construction code is concentrated. This
becomes more important when there are a large number of domain classes
or heavy querying. In these cases particularly, adding this layer
helps minimize duplicate query logic.
A Repository mediates between the domain and data mapping layers,
acting like an in-memory domain object collection. Client objects
construct query specifications declaratively and submit them to
Repository for satisfaction. Objects can be added to and removed from
the Repository, as they can from a simple collection of objects, and
the mapping code encapsulated by the Repository will carry out the
appropriate operations behind the scenes. Conceptually, a Repository
encapsulates the set of objects persisted in a data store and the
operations performed over them, providing a more object-oriented view
of the persistence layer. Repository also supports the objective of
achieving a clean separation and one-way dependency between the domain
and data mapping layers.
进一步阅读
有关存储库模式的更详细讨论,您应该查看 Patterns of Enterprise Application Architecture (Fowler, 2002) and Domain Driven Design(Evans,2003 年)。
我正在学习 Spring Data JPA,我遇到了术语“JPA 存储库”(具体来说 Spring数据 JPA 存储库)。我想了解术语“JPA 存储库”是一个一般概念(如 JPA - 标准规范)还是由 Spring 数据项目?
在这种情况下,"repository" 到底是什么意思?
What exactly does "repository" in this context means?
Repository is one of the patterns introduced in Patterns of Enterprise Application Architecture(马丁·福勒,2002 年)。在书中,Repository定义为:
Mediates between the domain and data mapping layers using a collection-like interface for accessing domain objects
A system with a complex domain model often benefits from a layer, such as the one provided by Data Mapper, that isolates domain objects from details of the database access code. In such systems it can be worthwhile to build another layer of abstraction over the mapping layer where query construction code is concentrated. This becomes more important when there are a large number of domain classes or heavy querying. In these cases particularly, adding this layer helps minimize duplicate query logic.
A Repository mediates between the domain and data mapping layers, acting like an in-memory domain object collection. Client objects construct query specifications declaratively and submit them to Repository for satisfaction. Objects can be added to and removed from the Repository, as they can from a simple collection of objects, and the mapping code encapsulated by the Repository will carry out the appropriate operations behind the scenes. Conceptually, a Repository encapsulates the set of objects persisted in a data store and the operations performed over them, providing a more object-oriented view of the persistence layer. Repository also supports the objective of achieving a clean separation and one-way dependency between the domain and data mapping layers.
进一步阅读
有关存储库模式的更详细讨论,您应该查看 Patterns of Enterprise Application Architecture (Fowler, 2002) and Domain Driven Design(Evans,2003 年)。