Hibernate cascade for All-delete-orphan use supplement

Source: Internet
Author: User
When a parent-child (Head-detail) relationship exists for both parties, and Cascade is All-delete-orphan, the parent object has the following features:
1. When the parent object is saved or updated, Cascade saves or updates all associated child objects, equivalent to Cascade Save-update
2. When the parent object is deleted, Cascade deletes all associated child objects, equivalent to cascade delete
3. Delete all child objects that are no longer associated with the parent object


Usage Supplement:
1. When a delete is made to a detail that has been updated by another person, the normal processing, sending SQL, does not appear the object does not exist the hint.
2. When updates are made to the detail that have been updated by others, the updatecounter of the head is inconsistent and prompts the multi-user to operate.
Even if the head of the Updatecounter modified to the latest value will also be due to detail of updatecounter inconsistent, prompt multi-user action prompts.
3. When a delete is made to a detail that has been physically deleted, it is normal but does not send SQL.
4. When the detail updatecounter is null, the head object inserts the update's detail data as the new data.
Rather than the update operation.
Possible occasions for Updatecounter null:
1. The picture is not taken into

The project property of 2.jsp does not correspond to the properties of the Resultmodel, causing the screen to be not successfully assigned a value


Cascade several values:

Save-update: Cascade Save (if a child object has been updated after load, it will also cascade updates). But it doesn't cascade delete

Delete: Cascade Delete, but no cascading save and update

All-delete-orphan: Automatically deletes child objects that are not part of the parent object when the parent-child relationship is lifted, and also supports cascading deletes and cascading save updates.

All: cascading deletes, cascading updates, but child objects are not automatically deleted when the parent-child relationship is lifted.

Delete-orphan: Deletes all objects associated with the current object disassociate

None: Cascade operations are not performed in all cases, default values.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.