Some Opinions on invers and cascade in hibernate

Source: Internet
Author: User

In the afternoon, I configured a simple bidirectional one-to-multiple relationship.

I can't remember the difference between invers and cascade.

I feel more confused when I read those online things.

Invers maintains the relationship between two tables.

However, cascade is also a cascade operation for two tables.

I think there is no difference.

I want to understand it later.

Invers should only maintain the relationship between tables.

It does not matter with actual data operations

Cascade is related to the actual operation of data and the table structure.

In layman's terms, for example, I have a one-to-many relationship between user and order2.






If invers = true is not set on the user end

Order is one end of multiple partitions-to-one default invers = flase

Then an error is reported.

Because the relationship between the two sides must be maintained.

It is equivalent

Create a user_id field in the order table for both ends.

In this way, the database reports an error.

Therefore, either party must hand over control or the other party must be 1. invers = true.

Either the insert and update values are set to false on multiple sides.


Cascade only manages the cascade operations of your actual data

No impact on the table


In my understanding, invers maintains the table relationship. cascade maintains the relationship between data operations.


I don't know if you have any questions.

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.