Data mapper pattern




In software engineering, the data mapper pattern is an architectural pattern. It was named by Martin Fowler in his 2003 book Patterns of Enterprise Application Architecture.[1] 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 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. The layer is composed of one or more mappers (or Data Access Objects), 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.




Contents






  • 1 Implementations


    • 1.1 Java/.NET


    • 1.2 Node.js / TypeScript


    • 1.3 PHP


    • 1.4 Python


    • 1.5 Ruby


    • 1.6 Elixir


    • 1.7 Golang




  • 2 See also


  • 3 References





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.js library


  • TypeORM library


  • Massive.js library

  • Prisma



PHP




  • Atlas ORM (data mapper, table data gateway, query builder, and PDO wrapper)[2]


  • Doctrine2 Object Relational Mapper (ORM) and the Database Abstraction Layer[3]



Python



  • SQLAlchemy library


Ruby



  • DataMapper library (Actually this library implemented the Active Record design pattern, its successor, DataMapper 2 (now ROM) aimed to actually implement the design pattern it was named after)


Elixir



  • Ecto persistence framework


Golang


  • Prisma


See also



  • Active record pattern

  • Object-relational mapping



References





  1. ^ Fowler, Martin (2003). Patterns of enterprise application architecture. Addison-Wesley. ISBN 978-0-321-12742-6..mw-parser-output cite.citation{font-style:inherit}.mw-parser-output .citation q{quotes:"""""""'""'"}.mw-parser-output .citation .cs1-lock-free a{background:url("//upload.wikimedia.org/wikipedia/commons/thumb/6/65/Lock-green.svg/9px-Lock-green.svg.png")no-repeat;background-position:right .1em center}.mw-parser-output .citation .cs1-lock-limited a,.mw-parser-output .citation .cs1-lock-registration a{background:url("//upload.wikimedia.org/wikipedia/commons/thumb/d/d6/Lock-gray-alt-2.svg/9px-Lock-gray-alt-2.svg.png")no-repeat;background-position:right .1em center}.mw-parser-output .citation .cs1-lock-subscription a{background:url("//upload.wikimedia.org/wikipedia/commons/thumb/a/aa/Lock-red-alt-2.svg/9px-Lock-red-alt-2.svg.png")no-repeat;background-position:right .1em center}.mw-parser-output .cs1-subscription,.mw-parser-output .cs1-registration{color:#555}.mw-parser-output .cs1-subscription span,.mw-parser-output .cs1-registration span{border-bottom:1px dotted;cursor:help}.mw-parser-output .cs1-ws-icon a{background:url("//upload.wikimedia.org/wikipedia/commons/thumb/4/4c/Wikisource-logo.svg/12px-Wikisource-logo.svg.png")no-repeat;background-position:right .1em center}.mw-parser-output code.cs1-code{color:inherit;background:inherit;border:inherit;padding:inherit}.mw-parser-output .cs1-hidden-error{display:none;font-size:100%}.mw-parser-output .cs1-visible-error{font-size:100%}.mw-parser-output .cs1-maint{display:none;color:#33aa33;margin-left:0.3em}.mw-parser-output .cs1-subscription,.mw-parser-output .cs1-registration,.mw-parser-output .cs1-format{font-size:95%}.mw-parser-output .cs1-kern-left,.mw-parser-output .cs1-kern-wl-left{padding-left:0.2em}.mw-parser-output .cs1-kern-right,.mw-parser-output .cs1-kern-wl-right{padding-right:0.2em}


  2. ^ "Atlas ORM – Atlas".


  3. ^ "Doctrine2 and ActiveRecord – Doctrine2". Doctrine2.









這個網誌中的熱門文章

12.7 cm/40 Type 89 naval gun

University of Vienna

Rikitea