@SubclassMapping not working with @BeanMapping.ignoreUnmappedSourceProperties
Expected behavior
@BeanMapping.ignoreUnmappedSourceProperties should not be ignored.
Actual behavior
I want to use @SubclassMapping and @BeanMapping.ignoreUnmappedSourceProperties on the same mapping method. The @BeanMapping.ignoreUnmappedSourceProperties seems to be ignored. If I remove the @SubclassMapping annotations the error (Unmapped source property: "id") disappears.
Steps to reproduce the problem
class Vehicle { public int price; } class Car extends Vehicle { public int seats; } class Truck extends Vehicle { public int capacity; } class VehicleDto { public int id; public int price; } class CarDto extends VehicleDto { public int seats; } class TruckDto extends VehicleDto { public int capacity; } @MapperConfig( unmappedSourcePolicy = ReportingPolicy.ERROR, unmappedTargetPolicy = ReportingPolicy.ERROR, subclassExhaustiveStrategy = SubclassExhaustiveStrategy.RUNTIME_EXCEPTION ) class Config { } @Mapper(config = Config.class) public abstract class VehicleMapper { @SubclassMapping(source = CarDto.class, target = Car.class) @SubclassMapping(source = TruckDto.class, target = Truck.class) @BeanMapping(ignoreUnmappedSourceProperties = { "id" }) public abstract Vehicle toVehicle(VehicleDto vehicle); @InheritInverseConfiguration @Mapping(target = "id", ignore = true) public abstract VehicleDto toVehicleDto(Vehicle vehicle); }
MapStruct Version
1.5.5