Writing today, when configuring a relationship, the cascade is then configured, with a value of false. Foggy, the result is very sad urge, has started on the error, made me, and then carefully check found that the original is cascade in doing that. Now summarize. By the way, review the inverse.
1.cascade Cascade, with it we will be more convenient to delete and update the operation. All cascade relationships are passively inserted or deleted as long as they are inserted or deleted at the source of the cascade. Cascade It is important to have a value, Saveorupdate, hibernate to determine whether an object is inserted or updated based on this attribute value, if the ID of the object does not exist then it is insert, otherwise it is update.
2.inverse inversion. The default is false, which means that both ends are to maintain the relationship. This means that if a student,teacher table. When a party specifies cascade to true in the configuration of HBM, that is to say that the relationship is maintained by the other party, in other words, the configuration file in party A is set to true in Cascade, then party B will not be affected by inserting a piece of data at this time. Only when party B inserts or deletes data will it operate on the party.
It is not right to configure cascade on both sides, in general the relationship is set on more than one side.
The difference between 3.cascade and inverse
Summary: Cascade defines the cascade relationship of objects to objects on both sides of the relationship, and inverse defines the relationship and the cascade relationship of the objects.
The values for both are: All:sava+update+delete
None: Cascading operations are not performed in all cases. This is the default value
Save-update: Performing a sava/update/saveorupdate is a cascade operation
Delete: Performs a cascade operation when the delete is executed.