Hibernate many-to-many association configuration file notation

Source: Internet
Author: User


Cmsuserentry

set<cmsroleentry> Roles =new cmsroleentry ();

Public void Get Roles (){

Return Roles ;

}

Public void Set Roles (set<cmsroleentry> cmsroleentrys) {

Thisnansroleentrys=cmsroleentrys;

}

Cmsroleentry

set<cmsuserentry> Users =new cmsuserentry ();

Public void Get Users (){

Return Users ;

}

Public void Set Users (set<cmsuserentry> cmsuserentrys) {

This . Users =cmsuserentrys;

}

Cms_role_config Intermediate Table

Users is a property of the set type in the current class

Jc_user_role This is the middle table .

role_id This is the middle table. role_id

user_id This is the middle table. user_id

Cmsuser Entry This is associated with the other party class

set name "users" &NBSP; table "Jc_user_role"

< Key column="role_id"/>

<Many-to-many column="user_id" class="CmsuserEntry"/>

</ Set >

Cms_user_config

set name "roles" table "Jc_user_role"

< Key column="user_id"/>

<Many-to-many column="role_id" class="Cmsrole"/>

</ Set >

If you have one or two more, you have an intermediate table.

Just use

recommends This is the property of the set type in the current class;

hj_user_recommendation This is the middle table .

  This is the current and intermediate table id Association (not many-to-many default is current id  associated field with intermediate table id corresponds)
  The class to be associated with

set name "recommends" table "hj_user_recommendation" >

key column "user_id"

< One-to-many class="cn.bizws.ismpNaNs.entity.main.UserRecommend"/>

</ Set >


Hibernate many-to-many association configuration file notation

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.