Cascade, two or more devices are connected in a certain way, and the effect of expansion is cascade. Hibernate cascade is used to describe the relationship between multiple tables in the database (one-to-one, one-to-many, multiple-to-many). When you perform some operation on the primary object, whether to perform similar operations on the associated slave object. Common cascade operations include:
(1) None: when saving, deleting, or modifying the current object, cascade operations on its affiliated object (associated object) is not performed, which is the default value.
(2) Save-Update: when saving and updating the current object, cascade save and update the affiliated object (temporary object, free object, etc ).
(3) Delete: When deleting the current object, cascade deleting the affiliated object
(4) All: cascade operations in all circumstances,
(5) delete-orphan: delete this object and delete the orphan object that is unassociated with the current object (only used in one-to-many relationship)
Every basic operation on a hibernate session, such as persist (), merge (), saveorupdate (), delete (), lock (), refresh (), evict (), replicate () all have a corresponding Cascade form.
Inverse: indicates "whether to discard the maintenance of the association relationship" (The Impact on the tables in the database when two objects are associated in Java). The default value of Hibernate is false. Used in the set definition of <one-to-operate> and <allow-to-operate> joining relationships. Inverse = "true" indicates that the object does not maintain the joining relationship. The value of this attribute is generally set to false when an ordered set is used (list, array, and so on. <one-to-least> maintaining an association is to update a foreign key. <allow-to-least> maintaining an association is to add or remove records in the intermediate table!
Differences between cascade and inverse:
As you can understand, cascade defines the cascading relationship between objects at both ends of the relationship to the object, while inverse defines the cascading relationship between the relationship and the object.