ModelMapper get confused in different properties

I have an object Studentextending an object Person.

public abstract class Person implements IIdentifiable {
    private String contactNumber;
    // other properties
    public String getContactNumber() {
        return contactNumber;
    }

    public void setContactNumber(String contactNumber) {
        this.contactNumber = contactNumber;
    }
}

public class Student extends Person {
    private String studentNumber;
    //Other properties
    public String getStudentNumber() {
        return studentNumber;
    }

    public void setStudentNumber(String studentNumber) {
        this.studentNumber = studentNumber;
    }
}

The student has a property studentNumber, and the person has a property contactNumber. When I map the Student object to StudentDto, it gets confused with the given properties.

public class StudentDto{
    private String studentNumber;
    public String getStudentNumber() {
        return studentNumber;
    }

    public void setStudentNumber(String studentNumber) {
        this.studentNumber = studentNumber;
    }
}

This only happens in certain cases. I wonder what would be the reason

1) The destination property com.cinglevue.veip.web.dto.timetable.StudentDto.setStudentNumber() matches multiple source property hierarchies:
com.cinglevue.veip.domain.core.student.StudentProfile.getStudent()/com.cinglevue.veip.domain.core.Person.getContactNumber()
com.cinglevue.veip.domain.core.student.StudentProfile.getStudent()/com.cinglevue.veip.domain.core.Student.getStudentNumber()
+4
source share

All Articles