Hibernate configuration file Details cascade inverse

Source: Internet
Author: User

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.

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.