0
Hello, I have a registered teacher class and want to change it by passing an array of subjects.
I have the following code:
teacher class:
//... atributos não importantes ao problema
@ManyToMany
@JoinTable(name = "teacher_x_lesson",
joinColumns = @JoinColumn(name = "id_teacher"),
inverseJoinColumns = @JoinColumn(name = "id_lesson"))
private List<Lesson> lesson;
At Source I got this far but I don’t know if I’m on the right track.
@PutMapping("/{id}/lesson")
@PreAuthorize("hasAuthority('ROLE_PUT_TEACHER') and #oauth2.hasScope('wride')")
public void putLessonTeacher(@PathVariable Long id, List<Lesson> idLesson) {
Teacher teacher = repository.findById(id).get();
teacher.setLesson(idLesson);
BeanUtils.copyProperties(idLesson, teacher, "id" );
}
In the Postman I am passing the following:
{
"lesson": [
{"id":1}
]
}
Hello Leonardo, let’s say I have the teacher class registered in the bank. However the attribute list of subjects constantly change. I’m not able to make this change by sending for example 3 materials at the same time via post
– Cleriston Lincoln