我正在尝试将border-width
类的值复制到StudentRequestForm
类。保存所有值,但StudentEntity
中的classI
字段未保存,映射到{ {1}} studentBean
。我希望我的ClassI值复制到classId
您可以在下面的推土机映射中登记
StudentEntity
................... ................ ;
推土机映射
classId
controller methood
public class StudentRequestForm {
private StudentModel studentbean;
public StudentModel getStudentbean() {
return studentbean;
}
public void setStudentbean(StudentModel studentbean) {
this.studentbean = studentbean;
}`enter code here`
public class StudentModel {
private int countryId,cityId,stateId,classI;
private String enrollmentId,firstName,lastName,gender,category,pincode,sectionName;
@Entity
@Table(name="students")
public class StudentEntity implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private int id;
private int age;
private String category;
private String pincode;
private int cityId;
@Column(name="class_id")
private int classId;
@Column(name="country_id")
private int countryId;
@Column(name="first_name")
private String firstName;
private String gender
答案 0 :(得分:1)
您正在将StudentModel
类传递给Dozer,但在您的映射中,您正在使用StudentRequestForm
。
所以,要么这样做
StudentEntity studententity = mapper.map(studentForm, StudentEntity.class);
OR
<class-a>com.myschool.entity.StudentModel</class-a>
<class-b>com.myschool.entity.StudentEntity</class-b>
<field>
<a>classI</a>
<b>classId</b>
</field>