EER Diagram
*Please note that course entity is not related to this question
Here I use save() method to save an object of Instructor to the database.[Instructor and InstructorDetails have a relationship of cascading allowed one to one bidirectional ,so saving the instructor object will save the instructorDetails object too] .In that case I got an error of object references an unsaved transient instance - save the transient instance before flushing.But when I use the persists() method that doesn't came.So but when I change the cascading type to CascadeType.ALL It was okay with the save() method too.But you can see I just removed the cascade type of REMOVE only in the following code ,so how it's going to be affected to the method like save() ?
Instructor Model class
public class Instructor{
@OneToOne(cascade={CascadeType.DETACH,CascadeType.MERGE,CascadeType.PERSIST,CascadeType.REFRESH})
//Here you can see I just only neglected the cascade type of REMOVE only
@JoinColumn(name="instructor_detail_id")
private InstructorDetails instructorDetail;
//
//
}
InstructorDetails Model class
public class InstructorDetails{
@OneToOne(mappedBy ="instructorDetail",cascade =
{CascadeType.DETACH,CascadeType.MERGE,CascadeType.PERSIST,CascadeType.REFRESH} )
//Here you can see I just only neglected the cascade type of REMOVE only
private Instructor instructor;
//
//
}