Maps an object to another via getters and setters methods
Maps an object to another via getters and setters methods
@Entity
public class Student {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;
private String name;
private String email;
private String password;
private LocalDate birthday;
@Column(name = "Curso_id")
private int courseId;
@ManyToOne
@JoinColumn(name = "Curso_id", insertable = false, updatable = false)
private Course course;
// getters, setters, equals, hashCode
}
public class StudentDTO {
private int id;
private String name;
private String email;
private String password;
private LocalDate birthday;
private int courseId;
// getters, setters, equals, hashCode
}
StudentDTO studentDTO = new StudentDTO();
studentDTO.setId(id);
studentDTO.setName(name);
studentDTO.setEmail(email);
studentDTO.setPassword(password);
studentDTO.setBirthday(birthday);
studentDTO.setCourseId(courseId);
Student student = ObjectMapper.map(studentDTO, Student.class);
Student student = new Student();
student.setId(id);
student.setName(name);
student.setEmail(email);
student.setPassword(password);
student.setBirthday(birthday);
student.setCourseId(courseId);
StudentDTO studentDTO = ObjectMapper.map(student, StudentDTO.class);
List<Discipline> disciplineList = execute(query, parameters);
List<DisciplineDTO> disciplineDTOList = ObjectMapper.map(disciplineList, DisciplineDTO.class)