Skip to content

Unmapped source properties error when source is mapped to a nested field of the target object #2781

@JCCorreale

Description

@JCCorreale

An example to reproduce this issue can be found in this repository

The issue is easily reproducible with this simple mapping:

@Mapping(target = "nested", source = "mySource")
MyTarget map(MySource mySource);

Where MyTarget.nested is of type MySource

When unmappedSourcePolicy is set to ReportingPolicy.ERROR, the report produces Unmapped source properties error (or warning in the case of ReportingPolicy.WARN)

The mapping code is generated correctly. For ReportingPolicy.ERROR, the following workaround is necessary in order to get a successful build:

@BeanMapping(ignoreUnmappedSourceProperties = { "field1", "field2" })

Where "field1", "field2" are the fields of MySource

MapStruct version is 1.4.2.Final

Best regards
JC

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions