it helps some times First of all is Source contains always one course why not make it a Course element instead of a List? If you do that the mapping would be much simpler. With your current setup it is a bit more complex.
around this issue Nesting on the target side as you are trying to use it is not supported yet. There's a feature request for this (issue #389), but we did not yet get to implementing this.
Nested Mapping in Mapstruct
By : Shivani
Date : March 29 2020, 07:55 AM
hop of those help? So I suppose you have the same hierarchy of objects on the target side, e.g. a SongDTO, LibraryDTO and TrackDTO. Then you'd have to declare a mapping method for each of those pairs of corresponding objects, configuring it via @Mapping as needed:
will be helpful for those in need Currently MapStruct can pass source parameters to single methods. In order to achieve what you are looking for (without using nested target types you would need to use something like @AfterMapping. It can look like: