In
software engineering
Software engineering is a branch of both computer science and engineering focused on designing, developing, testing, and maintaining Application software, software applications. It involves applying engineering design process, engineering principl ...
, the data mapper pattern is an
architectural pattern
Software architecture pattern is a reusable, proven solution to a specific, recurring problem focused on architectural design challenges, which can be applied within various architectural styles.
Examples
Some examples of architectural patte ...
. 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 Micros ...
that performs bidirectional transfer of data between a persistent data store (often a
relational database
A relational database (RDB) is a database based on the relational model of data, as proposed by E. F. Codd in 1970.
A Relational Database Management System (RDBMS) is a type of database management system that stores data in a structured for ...
) 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 ex ...
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 for many programming environments.
Java/.NET
*
MyBatis persistence framework
*
Hibernate (
NHibernate) persistence framework
Node.js / TypeScript
Bookshelf.jslibrary
TypeORMlibrary
Massive.jslibrary
PrismaObjection.jslibrary
MikroORMlibrary
LDkitObject Graph Mapper (OGM) for RDF data sources
PHP
AtlasORM (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)
CakePHPORM (PHP DataMapper ORM, query builder, and PDO wrapper)
Perl
DBIxref name="DBIx">
Python
*
SQLAlchemy 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)