I have a spring boot project with some entities, in specific, I have a Student Class with a DesiredCourses list which should be a Set<>.
When I use:
@OneToMany(mappedBy = "student", cascade = CascadeType.ALL)
public List<StudentDesiredCourseEntity> getStudentDesiredCourses() {
return studentDesiredCourses;
}
public void setStudentDesiredCourses(List<StudentDesiredCourseEntity> studentDesiredCourses) {
this.studentDesiredCourses = studentDesiredCourses;
}
Everything works fine but when I use
@OneToMany(mappedBy = "student", cascade = CascadeType.ALL)
public Set<StudentDesiredCourseEntity> getStudentDesiredCourses() {
return studentDesiredCourses;
}
public void setStudentDesiredCourses(Set<StudentDesiredCourseEntity> studentDesiredCourses) {
this.studentDesiredCourses = studentDesiredCourses;
}
I get
org.springframework.http.converter.HttpMessageNotReadableException",
"message":"Could not read JSON: (was java.lang.NullPointerException) (through reference chain: edu.cs6310.project4.entities.StudentEntity[\"studentDesiredCourses\"]->java.util.HashSet[0]); nested exception is com.fasterxml.jackson.databind.JsonMappingException: (was java.lang.NullPointerException) (through reference chain: edu.cs6310.project4.entities.StudentEntity[\"studentDesiredCourses\"]->java.util.HashSet[0])
Is there something I am missing or something extra that needs to be done?
Aucun commentaire:
Enregistrer un commentaire