我有一个扩展自Person
对象的Student
对象。
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;
}
}
学生拥有一个名为studentNumber
的属性,而人具有一个名为contactNumber
的属性。当我将学生对象映射到StudentDto
时,它会对给定属性感到困惑。
public class StudentDto{
private String studentNumber;
public String getStudentNumber() {
return studentNumber;
}
public void setStudentNumber(String studentNumber) {
this.studentNumber = studentNumber;
}
}
这只会在某些特定场合发生。我想知道原因是什么。
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()