Hibernate--cascade Cascade

Source: Internet
Author: User

Cascade:
Cascading: An object's chain operation
Cascade Save:
Cascade Save: When you save a party to a bidirectional relationship, the error is reported by default, and you should set the Cascade save in Customr, that is, when you manipulate an object by manipulating other associated objects
Configure the cascading update at the customer end:
cascade= "Save-update" class
In the test case, the value is manipulated for customer:
    Cust.getorders (). Add (O1);    Cust.getorders (). Add (O2);     Session.save (Cust);    
Cascade Delete:
Cascade Delete:
If you do not set a cascade delete, the foreign key of the data is set to NULL when the column information is deleted
If cascade Delete is set, the data associated with the foreign key is deleted when the information is deleted

Configure cascade Delete on the customer side:
cascade= "save-update, delete" class= "Com.roxy.hibernate.pojo.Order"/> </set>

Or

  <set name="Orders" cascade="All"

Hibernate--cascade Cascade

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.