Inverse Property
The inverse property is useful when maintaining an association relationship.
Indicates whether control is transferred. (works on one side)
Inverse, control reversal.
Inverse = false does not reverse; when there is control over the front
True control reversal; current party has no control
To maintain an association relationship, set the inverse property:
1. Save your data
have an impact.
If you set control inversion , that is inverse=true, then the Association is maintained through the departmental side. While saving the department, the data is saved, but the relationship is not maintained. The Foreign key field is NULL
2. Get Data
None.
3. Disassociate relationships?
have an impact.
Inverse=false , can be de-correlated
inverse=true , the Current party ( Department ) has no control and cannot disassociate the relationship
( no update statement is generated and no error is produced )
4. What is the effect of deleting data on an association?
have an impact.
Inverse=false, with control, can be deleted. Empty the foreign key reference before deleting the data.
Inverse=true, no control: If the deleted record has been referenced by foreign key, will error, violate the main foreign KEY reference constraint! If the deleted records are not referenced, you can delete them directly.
Cascade Property
Cascade indicates that a cascade operation "can be set to one or more of the other side"
None cascade operation, default value
Save-update Cascade Save or update
Delete Cascade deletion
Save-update,delete Cascade Save, UPDATE, delete
All ibid. Cascade Save, UPDATE, delete
Hibernate common interview question: Inverse and cascade difference?
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Hibernate Inverse properties and Cascade properties