I\'m using mapstruct to map my entity and dto classes... I\'m having problem with a loop on my mapper class...
I have no ideia what to do... This is my mapper classe
You have a cyclic dependency between VehicleType
and Brand
. You have 3 possibilities to resolve the cycles:
One mapper will always ignore the cyclic field. I see that you have @JsonIgnore
on the list of Brand
in the VehicleType
. You could ignore them via Mapping#ignore
in your mapper.
You will have explicit mappings that ignore what you don't need and use qualifiers to choose the appropriate methods. More info about qualifiers here in the documentation
Use the latest release of 1.2.0
(at the time of answering 1.2.0.RC1
and use the new @Context
parameter. Have a look at the mapping-with-cycles from the mapstruct examples repository. It solves cyclic mapping problems. You don't have to use Object
, you can also use your specific types instead.
NOTE: The 1.2.0
release does not offer "out of the box" solving of cyclic mapping, it needs to be done by the users explicitly.