Skip to content

@InheritInverseConfiguration doesn't pickup ignore mapping #1983

@imtiazShakil

Description

@imtiazShakil

@InheritInverseConfiguration doesn't apply ignore mapping

Example:
Student.java

@Getter
@Setter
public class Student {
  private String name;
  private String roll;
  private int age;
}

StudentDto.java

@Getter
@Setter
public class StudentDto {
  private String name;
  private String roll;
  private int age;
}

My Mapper interface is:

@Mapper()
public interface Mapper {
  @Mapping(target = "age", ignore = true)
  StudentDto studentToStudentDto(Student source);
  
  @InheritInverseConfiguration
  Student studentDtoToStudent(StudentDto source);
}

The expected behavior should be ignoring setAge() method from both implementation. but it's not working. This is what I get:

@Generated(
    value = "org.mapstruct.ap.MappingProcessor",
    date = "2019-12-08T20:18:06+0600",
    comments = "version: 1.3.1.Final, compiler: javac, environment: Java 11.0.5 (Amazon.com Inc.)"
)
public class MapperImpl implements Mapper {

    @Override
    public StudentDto studentToStudentDto(Student source) {
        if ( source == null ) {
            return null;
        }

        StudentDto studentDto = new StudentDto();

        studentDto.setName( source.getName() );
        studentDto.setRoll( source.getRoll() );

        return studentDto;
    }

    @Override
    public Student studentDtoToStudent(StudentDto source) {
        if ( source == null ) {
            return null;
        }

        Student student = new Student();

        student.setName( source.getName() );
        student.setRoll( source.getRoll() );
        student.setAge( source.getAge() );

        return student;
    }
}

As you can see in the studentDtoToStudent() method age property is not being ignored.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions