A cascading operation indicates how changes to the persistent object affect associated objects when an object is persisted. For instance, if the removed object is associated with other objects, what should happen to the others when the removed object is erased from the database?
I'll explain with an example. Consider the Teacher
class in the educational system application. Suppose that each teacher is associated with a single course, meaning the Teacher
class has a property of type Course
. If we use the TEACHER
and COURSE
tables, respectively, to store the Teacher
and Course
objects in the database, then corresponding to each Teacher
object is a single Course
object, and corresponding to each row in the TEACHER
table is a single row in the COURSE
table. In this situation, when a Teacher
object is removed, what do you expect to happen to its related Course
object?
The application's requirements may force you to either delete the associated object or to ignore it. In Hibernate...