学生课程双向多对多:
Subject.java
//关系集合
@ManyToMany
(targetEntity=Student.
class
)
@JoinTable
(name=
"STUDENT_SUBJECT"
,
joinColumns=
@JoinColumn
(name=
"SUBJECT_ID"
,referencedColumnName=
"ID"
),
inverseJoinColumns=
@JoinColumn
(name=
"STUDENT_ID"
,referencedColumnName=
"ID"
))
private
Set students;
Student.java
//关系集合
@ManyToMany
(targetEntity=Subject.
class
)
@JoinTable
(name=
"STUDENT_SUBJECT"
,
joinColumns=
@JoinColumn
(name=
"STUDENT_ID"
,referencedColumnName=
"ID"
),
inverseJoinColumns=
@JoinColumn
(name=
"SUBJECT_ID"
,referencedColumnName=
"ID"
))
private
Set subjects;
用户角色双向多对多:
IDMUser.java
@ManyToMany(targetEntity = IDMBizRole.class)
@JoinTable(name = "IDMUSERBIZROLE",
joinColumns = @JoinColumn(name = "USERID", referencedColumnName = "USERID"),
inverseJoinColumns = @JoinColumn(name = "BIZROLEID", referencedColumnName = "ROLEID"))
private Set<IDMBizRole> idmroles = new HashSet<IDMBizRole>();
IDMBizRole.java
@ManyToMany(targetEntity=IDMUser.class)
@JoinTable(name="IDMUSERBIZROLE",
joinColumns=@JoinColumn(name="BIZROLEID",referencedColumnName="ROLEID"),
inverseJoinColumns=@JoinColumn(name="USERID",referencedColumnName="USERID"))
private Set<IDMUser> users = new HashSet<IDMUser>();