Hibernate inverse effect

Source: Internet
Author: User

Inverse is the basic concept in hibernate bidirectional relationship. The real function of inverse is to specify which side to maintain the association between. When a party specifies "Inverse=false" (the default), then that party is responsible for the relationship, and that is how hibernate generates SQL to maintain the associated records!

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/72/F8/wKioL1XxNEDzJbLNAADqgTUZ3XU730.jpg "title=" 1.png " alt= "Wkiol1xxnedzjblnaadqgtuz3xu730.jpg"/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/72/F8/wKioL1XxNI-x4_LOAAGfNpNJ_Qc726.jpg "title=" 5.png " alt= "Wkiol1xxni-x4_loaagfnpnj_qc726.jpg"/>

If you set inverse to False, you will print more than one SQL statement

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/72/F8/wKioL1XxNEuAxqHYAALoFp18cMQ718.jpg "title=" 2.png " alt= "Wkiol1xxneuaxqhyaalofp18cmq718.jpg"/>650) this.width=650; src= http://s3.51cto.com/wyfs02/M02/72/F8/ Wkiol1xxnfbqvgtuaag018l0wsi199.jpg "title=" 3.png "alt=" Wkiol1xxnfbqvgtuaag018l0wsi199.jpg "/>

If you change the inverse configuration to true then the result will print 2 statements

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/72/FB/wKiom1XxMuOgOSbIAACxCZjLg_c647.jpg "title=" 6.png " alt= "Wkiom1xxmuogosbiaacxczjlg_c647.jpg"/>650) this.width=650; src= http://s3.51cto.com/wyfs02/M01/72/F8/ Wkiol1xxnrirybviaaca8danxn8347.jpg "title=" 7.png "alt=" Wkiol1xxnrirybviaaca8danxn8347.jpg "/>

One-to-many, if you want one side to maintain off

The "one" side of each object that is associated with the "one" object when inserting or deleting "a". And if the "many" aspect of maintaining the relationship there will be no update operation, because the relationship is in the object of the multi-party, directly into the insertion or deletion of multi-party objects on the line



This article is from the "Lao Niu Java" blog, please be sure to keep this source http://liuyj.blog.51cto.com/2340749/1693459

Hibernate inverse effect

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.