Files
java-design-patterns/data-mapper
Vaibhav Agrawal 7782203383 docs: Add tutorial links to patterns (#1901)
* Add API Gateway tutorial links

* Add Model View Controller tutorial links

* Add Data Access Object tutorial links

* Add Data Transfer Object tutorial links

* Add Data Mapper tutorial links

Co-authored-by: Ilkka Seppälä <iluwatar@users.noreply.github.com>
2022-11-09 21:32:06 +02:00
..
2019-12-07 18:03:49 +02:00
2022-09-14 23:22:24 +05:30
2022-09-14 23:22:24 +05:30

title, category, language, tags
title category language tags
Data Mapper Architectural en
Decoupling

Intent

A layer of mappers that moves data between objects and a database while keeping them independent of each other and the mapper itself

This layer consists of one or more mappers (or data access objects) that perform data transfer. The scope of mapper implementations varies. A generic mapper will handle many different domain entity types, a dedicated mapper will handle one or a few.

Explanation

Real-world example

When accessing web resources through a browser, there is generally no need to interact with the server directly; the browser and the proxy server will complete the data acquisition operation, and the three will remain independent.

In plain words

The data mapper will help complete the bi-directional transfer of persistence layer and in-memory data.

Wikipedia says

A Data Mapper is a Data Access Layer that performs bidirectional transfer of data between a persistent data store (often a relational database) and an in-memory data representation (the domain layer).

Programmatic example

Class diagram

alt text

Applicability

Use the Data Mapper in any of the following situations

  • when you want to decouple data objects from DB access layer
  • when you want to write multiple data retrieval/persistence implementations

Tutorials

Known uses

Consequences

Neatly mapped persistence layer data Data model follows the single function principle

Credits