I have an object "Instance" with another object "Course" inside. When trying to persist a new Instance object, I get the following error if Course is null:
java.lang.IllegalStateException: During synchronization a new object was found through a relationship that was not marked cascade PERSIST: null
Here is my annotation for course:
@OneToOne(cascade = CascadeType.REFRESH,optional=true)
public Course getCourse() {
return course;
}
I don't see why it's trying to persist something that's null. If it's null, it should just leave that field null in the database right?