In
software engineering
Software engineering is a systematic engineering approach to software development.
A software engineer is a person who applies the principles of software engineering to design, develop, maintain, test, and evaluate computer software. The term '' ...
, the data mapper pattern is an
architectural pattern. It was named by
Martin Fowler in his 2003 book ''Patterns of Enterprise Application Architecture''. The interface of an object conforming to this pattern would include functions such as Create, Read, Update, and Delete, that operate on objects that represent domain entity types in a data store.
A Data Mapper is a
Data Access Layer A data access layer (DAL) in computer software is a layer of a computer program which provides simplified access to data stored in persistent storage of some kind, such as an entity-relational database. This acronym is prevalently used in Microsof ...
that performs bidirectional transfer of data between a persistent data store (often a
relational database) and an in-memory data representation (the domain layer). The goal of the pattern is to keep the in-memory representation and the persistent data store independent of each other and the data mapper itself. This is useful when one needs to model and enforce strict business processes on the data in the domain layer that do not map neatly to the persistent data store.
The layer is composed of one or more mappers (or
Data Access Object
In software, a data access object (DAO) is a pattern that provides an abstract interface to some type of database or other persistence mechanism. By mapping application calls to the persistence layer, the DAO provides data operations without expo ...
s), performing the data transfer. Mapper implementations vary in scope. Generic mappers will handle many different domain entity types, dedicated mappers will handle one or a few.
Implementations
Implementations of the concept can be found in various
frameworks
A framework is a generic term commonly referring to an essential supporting structure which other things are built on top of.
Framework may refer to:
Computing
* Application framework, used to implement the structure of an application for an op ...
for many programming environments.
Java/.NET
*
MyBatis
MyBatis is a Java persistence framework that couples objects with stored procedures or SQL statements using an XML descriptor or annotations.
MyBatis is free software that is distributed under the Apache License 2.0.
MyBatis is a fork of iBATI ...
persistence framework
*
Hibernate (
NHibernate
NHibernate is an object–relational mapping (ORM) solution for the Microsoft .NET platform. It provides a framework for mapping an object-oriented domain model to a traditional relational database. Its purpose is to relieve the developer from a ...
) persistence framework
Node.js / TypeScript
Bookshelf.jslibrary
TypeORMlibrary
Massive.jslibrary
PrismaObjection.jslibrary
MikroORMlibrary
PHP
*
Atlas
An atlas is a collection of maps; it is typically a bundle of maps of Earth or of a region of Earth.
Atlases have traditionally been bound into book form, but today many atlases are in multimedia formats. In addition to presenting geograp ...
ORM (data mapper, table data gateway, query builder, and PDO wrapper)
*
Doctrine2 Object Relational Mapper (ORM) and the Database Abstraction Layer
CycleORM (PHP DataMapper ORM and Data Modelling Engine)
Python
*
SQLAlchemy
SQLAlchemy is an open-source SQL toolkit and object-relational mapper (ORM) for the Python programming language released under the MIT License.
Description
SQLAlchemy's philosophy is that relational databases behave less like object collectio ...
library
mincePylibrary
Ruby
DataMapper library (Actually this library implemented the Active Record design pattern, its successor, DataMapper 2 (no
ROM aimed to actually implement the design pattern it was named after)
Elixir
Ectopersistence framework
See also
*
*
References
{{DEFAULTSORT:Data mapper pattern
Software design patterns
Architectural pattern (computer science)