Skip to content

@InheritInverseConfiguration and @Mapping(target:"bean.childProperty", ignore=true) do not play together #2278

Description

@neowin35
public interface CarMapper {
    class Details {
        public String brand;
        public String model;
    }
    class DetailsDTO {
        public String brand;
    }
    class Car {
        public Details details;
    }
    class CarDTO {
       public DetailsDTO detailsDTO;
    }

    @Mapping(target = "detailsDTO", source = "details")
    CarDTO map(Car in);

    @InheritInverseConfiguration
    @Mapping(target = "details.model", ignore = true)
    Car map(CarDTO in);
}

This example mapper results at 1.3.1.Final to this code to be generatedfor the BrandDTO -> Brand mapping:

protected Details detailsDTOToDetails(DetailsDTO detailsDTO) {
        if ( detailsDTO == null ) {
            return null;
        }
        Details details = new Details();
        details.brand = detailsDTO.brand;

        return details;
    }

However after upgrading to 1.4.1.Final this is what gets generated:

protected Details carDTOToDetails(CarDTO carDTO) {
        if ( carDTO == null ) {
            return null;
        }
        Details details = new Details();

        return details;
    }

For some strange reason mapstruct is now trying to map CarDTO to Details. In case I specify the full path to the property to ignore like in.details.model than it seems to work. Is that an intentional change or just a regression issue?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions