Data Mapper


pattern architecture

The Data Mapper is a layer that separates domain objects from database access. This layer accommodates all the knowledge about the database like schema or query. Thanks to that, domain objects do not have to know about the database.

For example, retrieving data from a database could be like this:

groot = person_mapper.find(1)

Updating data could be like this:

person_mapper.update(groot)

The mapper could use Identity Map to use the objects already loaded.

See Also

  • Repository mediates between the domain and data mapping layers.

References

  1. Martin Fowler, Patterns of Enterprise Application Architecture, Chapter 10. Data Source Architectural Patterns, Data Mapper.
  2. https://martinfowler.com/eaaCatalog/dataMapper.html