Filter
Exclude
Time range
-
Near
Recently, while studying the second module of the Spring Boot Cohort by Coding Shuttle, I came across a topic called ModelMapper. At first, I assumed it was just another utility library. However, after understanding its purpose, I realized how much repetitive code it can eliminate in a Spring Boot application. In real-world applications, sending entity objects directly to clients is not considered a good practice because entities may contain sensitive information that should not be exposed. That's where DTOs (Data Transfer Objects) come into play. DTOs allow us to send only the required data to the client while keeping internal details secure. The challenge, however, is that converting entities to DTOs and DTOs back to entities often requires writing a lot of boilerplate mapping code. This is where ModelMapper becomes extremely useful. It automatically maps fields between objects, making conversions much cleaner and reducing manual effort. Some common use cases include: ✅ Entity → DTO for API responses ✅ DTO → Entity for create and update operations ✅ Mapping collections such as List<Entity> → List<DTO> Additionally, ModelMapper can be used alongside Optional for safer null handling and ResponseEntity for better API response management. Learning small tools like these reminds me that writing less code often leads to cleaner and more maintainable applications. #SpringBoot #Java #BackendDevelopment #CodingShuttle #ModelMapper #SoftwareDevelopment
1
1
3
67
Implemented DTO Model Mapper to make my data transfer cleaner, reduce boilerplate, and keep my controllers clean. How do you handle mapping in your Spring projects? Do you prefer manual mapping or libraries like ModelMapper? #springboot #java
6
162
Replying to @SumitM_X
Best paired with a mapping framework like Jmapper, Mapstruct or Modelmapper (my personal favorite) to make your life much easier :)
1
5
654
Day 85 of #100DaysOfCode (#JavaRevision) ☕ #SpringBoot - Understood the role of the Service layer in a Spring Boot application - How it acts as a mediator between the presentation and persistence layers - Learned how separation of concerns is maintained between DTOs and Entities using Controllers and Services - Used ModelMapper to handle clean, bi-directional mapping between Entity and DTO objects #Java #SpringBoot #Backend #100DaysOfCode
7
227
Replying to @5eniorDeveloper
Yo casi no lo uso, de hecho hasta hace unos días estaba convencido que usaba reflection, alguien en el stream me cerró el culo y me hizo darme cuenta de que no. Solo lo use una vez, hice un video en youtube porque lo tenía un proyecto en el que estaba trabajando y nunca más lo toqué. Tiene casi los mismos "problemas" que lombok, pero me parece mucho menos invasivo, una librería que me parece mejor (aunque aún no le he explorado mucho) es ModelMapper. Solo hay que agregar la dependencia y listo ya se empieza a trabajar con ella, sin nada que se meta en el tiempo de compilación. ModelMapper es lo que yo pensé que era MapStruct.
2
37
19 Oct 2025
Mapstruct or ModelMapper.
3
3,148
3 Sep 2025
When working with APIs in Spring Boot, you often hear these three terms - DTOs, ModelMapper, Jackson. Lets understand them: 1. DTO (Data Transfer Object) A DTO is a plain Java object used to transfer data between layers (Controller <-> Service <-> Client). Why not use Entities directly? Entities may contain extra fields (like DB IDs, audit info) that clients shouldn’t see. Prevents exposing sensitive info. Keeps API contracts clean and stable, even if DB schema changes. Example: class UserDTO { private String name; private String email; } 2. ModelMapper ModelMapper is a library to map between DTOs and Entities automatically. Without it, you’d manually write: dto.setName(entity.getName()); dto.setEmail(entity.getEmail()); With ModelMapper: UserDTO dto = modelMapper.map(userEntity, UserDTO.class); Saves boilerplate, but: Needs config for complex mappings. Can hide mapping issues if overused. 3. Jackson Jackson is the library Spring Boot uses for JSON serialization & deserialization. Converts: Java -> JSON (when sending API response). JSON -> Java (when receiving request body). Example: { "name": "Sumit", "email": "sumit@email.com" } -> gets converted into UserDTO automatically in your Controller. How They Work Together: Jackson handles JSON <-> DTO. ModelMapper handles DTO <->Entity. DTOs act as the contract layer between external clients and your internal models.

4
13
204
7,411
6 Jul 2025
What is a DTO(Data Transfer Object) and Why Use Them? Let’s say you have two entity classes in your Spring Boot app: class Account { Long id; String type; Double balance; Customer customer; } class Customer { Long id; String name; String email; } Now the client says: "We need account details along with the customer name and email in a single response." You might think of modifying your entity to add/expose fields, but don’t do that. Why NOT modify entities? Entities are tied to your DB structure, not your API. Entities often have lazy-loaded relationships, which can cause LazyInitializationException. You end up coupling your DB design to frontend needs, which is fragile and messy. What to do instead? Use a DTO (Data Transfer Object): class AccountCustomerDTO { Long accountId; String accountType; Double balance; String customerName; String customerEmail; } Now, your controller also becomes clean and client-friendly. Benefits of DTOs: Clean separation between DB model and API contract Avoids exposing unnecessary or risky data Easier to customize response formats Plays well with versioning and frontend-specific needs Works smoothly with tools like MapStruct or ModelMapper DTOs are like wrappers ,they carry just what the client needs, nothing more.
19
43
425
24,557
12 Jun 2025
Replying to @kawasima
ありがとうございます。 ModelMapperでも同様のことがあったりしました。 strictモードがあったんでその設定で回避しました。Jacksonにはそのような設定はなさそうですよねー。きっと。
1
2
60
Replying to @myfear
IMO mappers like MapStruct or Modelmapper are an anti-pattern
2
2
253
When doing mappings for Java/Spring devs there are three ways to do it: Manual Mapping MapStruct ModelMapper Each has its pros and cons. 🧵Let’s break them down 👇
4
1
10
740
What is ModelMapper? A Java library that simplifies object mapping Perfect for converting between Entities and DTOs in APIs! #java #springboot #modelmapper #ayshriv
2
10
86
4,676
Replying to @RWanjie
Why use BeanUtils? Have you tried ModelMapper?
1
3
89
🎯 Make an informed choice between MapStruct and ModelMapper for your Java projects. Our comparative analysis highlights performance, type-safety, and flexibility. #Java #MapStructVsModelMapper buff.ly/4a8POhj

3
26
1,632
🔄 Looking to streamline object mapping in Java? Discover the trade-offs between MapStruct and ModelMapper in our comparative review. #Java #MapStruct #ModelMapper buff.ly/4a8POhj

2
6
1,176
📊 Get the inside scoop on Java mapping frameworks. Our analysis of MapStruct vs. ModelMapper reveals their strengths and weaknesses. #JavaDev #MappingTools buff.ly/4a8POhj

4
15
1,268
🔧 Struggling with bean mapping in Java? Our comparative analysis of MapStruct vs. ModelMapper shows which framework fits your needs. #Java #MapStruct #ModelMapper buff.ly/4a8POhj

3
27
1,473
🌟 MapStruct offers type-safe, generated code, while ModelMapper provides flexible runtime mapping. See how they stack up in our analysis! #JavaDev #MappingTools buff.ly/4a8POhj

1
3
7
982
💥 When performance matters, MapStruct’s compile-time magic might be your best bet. But what about ModelMapper? Explore the debate! #Java #Programming #MapStructVsModelMapper buff.ly/4a8POhj

2
11
1,027
⚡ Boost your Java mapping efficiency! Learn how MapStruct and ModelMapper compare on speed, safety, and ease-of-use. #Java #Mapping #DevTools buff.ly/4a8POhj

1
4
900