When I try to delete a "Course" object, I get this exception:
Referential integrity constraint violation: "FKCE6C075833B16F41: PUBLIC.TEACHER_COURSE FOREIGN KEY(COURSES_ID) REFERENCES PUBLIC.COURSE(ID)" SQL statement: delete from Course where id=?
The "Course" class looks like this:
@Entity
public class Course extends Model {
@ManyToOne
public Teacher teacher;
...
}
The "Teacher" class looks like this:
@Entity
public class Teacher extends Model {
@OneToMany(mappedBy="teacher", cascade=CascadeType.ALL)
public List<Course> courses;
...
}
Whenever I try to delete a "Course" from my controller (using the delete() method), I get the exception above. How do I fix it? I've tried various ways of mapping. Do I need to fix the schema of the database somewhere?
Thanks for all the help! This is my first post here, if there's anything I need to make clearer, please let me know!