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