I have a dto that has two fields. account and date opened. Using the mapper, I mapped only account and not the date opened. However the implementation is adding unmapped field as well. I apologize if this has been addresses before. Any input would be greatly appreciated.
Can you share your mapper definition and mapper types? Have you tried to
use @Mapping#ignore()?
@PFStruct are the name of the date opened field same in the dto and the other object? If they are then MapStruct automatically maps them. If you don't want to map fields that have the same name you have to explicitly ignore them via @Mapping#ignore() like @gunnarmorling suggested.
*Update - didn't see filiphr's explanation. yes the source and destination names are identical. * I will give it a try. Thank you both.
@PFStruct our replies were almost in the same time 馃槃.
For more information you can have a look at Basic Mappings from our documentation.
This paragraph explains how the mapping is done:
In the generated method implementations all readable properties from the source type (e.g. Car) will be copied into the corresponding property in the target type (e.g. CarDto). If a property has a different name in the target entity, its name can be specified via the @Mapping annotation.
If it is OK for you I will close the issue
Absolutely! Thank you for quick response.