Im learning one to many mapping and this is my field for courses
@OneToMany(mappedBy = "instructor", cascade = {CascadeType.MERGE, CascadeType.PERSIST, CascadeType.DETACH, CascadeType.REFRESH}) private List<Course> courses; I have some other fields, i will update question if someone request but i think other fields and code is not important because everything is okey.
My problem is, when I go to auto generate getters and setters im getting this:
public List<com.hibernate.demo.entity.Course> getCourses() { return courses; } As you can see for some reason, parameter for list is full package path with name of List field parameter. I can manually change it to just Course but that doesnt work after when I try to create this method.
public void add(Course tempCourse) { if (courses == null) { courses = new ArrayList<>(); } courses.add(tempCourse); } After manually change List parameter to Course my error for method is Cannot access com.hibernate.demo.entity.Course so that mean he is still searching for full package even I put parameter to Course. Error is on course.add(tempCourse);
Also, I created same List in Course class with Instructor paramter and everything works fine.
https://stackoverflow.com/questions/67051789/problem-with-creating-getters-and-setters-with-list April 12, 2021 at 09:58AM
没有评论:
发表评论