From 08aafce66d6e1de042faaa17413fc7327210ec3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ilkka=20Sepp=C3=A4l=C3=A4?= Date: Sat, 25 May 2024 11:02:41 +0300 Subject: [PATCH] docs: update data mapper --- data-mapper/README.md | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/data-mapper/README.md b/data-mapper/README.md index 9bf3f1d51..a6ce8894d 100644 --- a/data-mapper/README.md +++ b/data-mapper/README.md @@ -5,6 +5,7 @@ language: en tag: - Data access - Decoupling + - Domain - Object mapping - Persistence --- @@ -19,9 +20,9 @@ The Data Mapper pattern aims to create an abstraction layer between the database ## Explanation -Real world example +Real-world example -> When a user accesses a specific web page through a browser, he only needs to do several operations to the browser. The browser and the server will take the responsibility of saving data separately. You don't need to know the existence of the server or how to operate the server. +> Consider a library system where books are stored in a database with complex relationships and various attributes such as title, author, publication year, and genre. In this scenario, a Data Mapper pattern can be used to map the database records of books to in-memory objects in the application. The Data Mapper would handle the retrieval, storage, and update of book objects in the database, allowing the application's business logic to work directly with the book objects without concern for the underlying database structure. This separation makes it easier to change the database schema without affecting the business logic, and vice versa. In plain words @@ -118,7 +119,7 @@ Program output: ## Class diagram -![alt text](./etc/data-mapper.png "Data Mapper") +![Data Mapper](./etc/data-mapper.png "Data Mapper") ## Applicability @@ -130,16 +131,15 @@ Use the Data Mapper in any of the following situations ## Tutorials -* [Spring Boot RowMapper](https://zetcode.com/springboot/rowmapper/) -* [Spring BeanPropertyRowMapper tutorial](https://zetcode.com/spring/beanpropertyrowmapper/) -* [Data Transfer Object Pattern in Java - Implementation and Mapping (Tutorial for Model Mapper & MapStruct)](https://stackabuse.com/data-transfer-object-pattern-in-java-implementation-and-mapping/) +* [Spring Boot RowMapper (ZetCode)](https://zetcode.com/springboot/rowmapper/) +* [Spring BeanPropertyRowMapper tutorial (ZetCode)](https://zetcode.com/spring/beanpropertyrowmapper/) +* [Data Transfer Object Pattern in Java - Implementation and Mapping (StackAbuse)](https://stackabuse.com/data-transfer-object-pattern-in-java-implementation-and-mapping/) ## Known uses * ORM frameworks such as Hibernate in Java. * Data access layers in enterprise applications where business logic and database management are kept separate. * Applications requiring database interactions without tying the code to a specific database implementation. -* [SqlSession.getMapper()](https://mybatis.org/mybatis-3/java-api.html) ## Consequences @@ -164,7 +164,6 @@ Trade-offs: ## Credits -* Patterns of Enterprise Application Architecture -* [Java Persistence with Hibernate](https://amzn.to/3VNzlKe) * [Clean Architecture: A Craftsman's Guide to Software Structure and Design](https://amzn.to/3xyEFag) -* [Data Mapper](http://richard.jp.leguen.ca/tutoring/soen343-f2010/tutorials/implementing-data-mapper/) +* [Java Persistence with Hibernate](https://amzn.to/3VNzlKe) +* [Patterns of Enterprise Application Architecture](https://amzn.to/3WfKBPR)