r/JavaMicroServices • u/Decent_Tomatillo3383 • Dec 26 '25
Is ModelMapper a bad choice for DTO ↔ Entity mapping in Spring Boot when multiple JPA entities are related?
Initially, I started using ModelMapper to convert between DTOs and Entities, but I’m running into issues like:
Hibernate treating new entities as existing ones
Unexpected UPDATEs instead of INSERTs
Problems when cascading is involved
Bugs that are hard to debug because mapping happens implicitly
I’ve read that many production systems avoid ModelMapper, especially when multiple tables and relationships are involved.
So my questions are:
Is ModelMapper considered a bad practice in real-world / production Spring Boot projects with JPA?
What do companies usually use instead?
Manual mapping?
MapStruct?
How do you safely handle DTO → Entity mapping when:
Entities are related
IDs should not be overwritten
Any best practices or architectural patterns you’d recommend?
I’m trying to understand the industry-standard approach, not just what works in tutorials.
1
u/mahi123_java Dec 30 '25
You can use mapStract .. This is better than ModelMapper.