Hibernate cascade Configuration

Source: Internet
Author: User

Annotation method Configuration

1) One-to-many

Private list<tnoticeaffix> FFI;
@OneToMany (Cascade =cascadetype.all,mappedby= "T_notice", Targetentity=tnoticeaffix.class)
Public list<tnoticeaffix> Getffi () {
return FFI;
}

2) One-to-one (one-to-one and one-to-many configurations)

Private Ltnoticeaffix FFI;
@OneToMany (Cascade =cascadetype.all,mappedby= "T_notice", Targetentity=tnoticeaffix.class)
Public Tnoticeaffix Getffi () {
return FFI;
}

3)

Private set<tmenu> menus= new hashset<tmenu> ();

@ManyToMany
@JoinTable (name= "T_role_menu", joincolumns [email protected] (name= "RID"), inversejoincolumns [email protected] (name= "Mid"))
Public set<tmenu> Getmenus () {
return menus;
}

2. Configuration file methods

1) One-to-many

<set lazy= "true" name= "user" cascade= "all" inverse= "false" Fetch= "select" batch-size= "2" >
<key column= "userid" ></key>
<one-to-many class= "cn.hd.onetomany.TUserconf"/>
</set>

2) One-to-one

<!--PRIMARY Key Association--
<one-to-one name= "Details" class= "Cn.hd.model.TUserdetails" ></one-to-one>
<one-to-one name= "conf" class= "cn.hd.model.TUserconf" property-ref= "user" cascade= "save-update" ></ One-to-one>

Hibernate cascade Configuration

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.