You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When mapping JPA entities that contain bi-directional relations into DTOs, the mapper gets stuck in StackOverflow error for obvious reason. One must manually handle those mappings using available means, such as @Mapper(uses = ...) and @Mapping(qualifiedByName = ...), but in certain scenarios, it's a significant amount of work.
Generated Code
My suggestion is to introduce new method Integer maxDepth() into the @Mapper annotation, which would stop the recursive generation of mapping code after N recursions. This is sufficient to transfer entity and entities contained @manytoone, @OneToMany, @manytomany relations but not deeper.
Possible workarounds
No response
MapStruct Version
No response
The text was updated successfully, but these errors were encountered:
I am not sure that this is something that we can do. How would this work when you have separate mappers for the parent and child?
In my opinion this is something that should be fixed on the defining mapper side. You can define a custom mapping method that can then be used to ignore the second level of the mapping.
Use case
When mapping JPA entities that contain bi-directional relations into DTOs, the mapper gets stuck in StackOverflow error for obvious reason. One must manually handle those mappings using available means, such as
@Mapper(uses = ...)
and@Mapping(qualifiedByName = ...)
, but in certain scenarios, it's a significant amount of work.Generated Code
My suggestion is to introduce new method
Integer maxDepth()
into the@Mapper
annotation, which would stop the recursive generation of mapping code after N recursions. This is sufficient to transfer entity and entities contained @manytoone, @OneToMany, @manytomany relations but not deeper.Possible workarounds
No response
MapStruct Version
No response
The text was updated successfully, but these errors were encountered: