2015-08-13 23:54:40 +02:00
|
|
|
---
|
|
|
|
layout: pattern
|
|
|
|
title: Repository
|
|
|
|
folder: repository
|
2015-08-15 18:03:05 +02:00
|
|
|
permalink: /patterns/repository/
|
2015-08-20 21:40:07 +02:00
|
|
|
categories: Architectural
|
|
|
|
tags: Java
|
2015-08-13 23:54:40 +02:00
|
|
|
---
|
|
|
|
|
|
|
|
**Intent:** Repository layer is added between the domain and data mapping
|
|
|
|
layers to isolate domain objects from details of the database access code and
|
|
|
|
to minimize scattering and duplication of query code. The Repository pattern is
|
|
|
|
especially useful in systems where number of domain classes is large or heavy
|
|
|
|
querying is utilized.
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|
**Applicability:** Use the Repository pattern when
|
|
|
|
|
|
|
|
* the number of domain objects is large
|
|
|
|
* you want to avoid duplication of query code
|
|
|
|
* you want to keep the database querying code in single place
|
|
|
|
* you have multiple data sources
|
|
|
|
|
|
|
|
**Real world examples:**
|
|
|
|
|
2015-08-15 18:03:05 +02:00
|
|
|
* [Spring Data](http://projects.spring.io/spring-data/)
|