hibernate有两个一对多的Set时怎么写hbm

有两个类,Course和Student,其中Student里面有两个放Course的Set:
class Course
{
...
};
class Student
{
private Set goodCourseSet;
private Set badCourseSet;
...
};

[b]问题描述:[/b]
如果Student里只有一个Course的Set,底层Course表只要加一列StudentID属性就可以了,但现在Student对应了两个Course集,仅仅加一列StudentID属性肯定已经区分不出来到底对应哪个Course集了,所以底层表结构要变,这样hbm文件肯定也要变,但我不知该怎么变。

[b]目前已有的分析:[/b]
下面是我猜想出来的一种写法,由于需要区分出某Student的Course是good还是bad,需要在Course表中增加两个字段,studentID和isGood,isGood的值就是用来区分不同CourseSet的,我下面写的只是表示个大概意思,其中[color=red]value[/color]只是希望用来区分是哪个Set,也许实际当中不存在这个属性。


























[code="java"]


[/code]
set 可以有个where的限制条件

不过我觉得很奇怪 你为什么一定要用2个set呢
你完全可以这样

[code="java"]
class Student
{
private Set courseSet;
...
};

[/code]
[code="java"]
class Course
{
private int type //good 或者 bad
...
};

[/code]
而且很明显
course 和 student 应该是 many to many 的
所有你最好又张中间表比如
[code="java"]
class CourseStudent{
private Student;
private Course;
private type;
}
[/code]
你想找student的bad course 用这个
select c.Course from CourseStudent c where c.type='bad'

可以百度一下联合主键,将Student里面两个Course看成一个对象。

[b]Models.java[/b]
[code="java"]
public class Models implements java.io.Serializable {
private Integer id;
private Set modelpsts = new HashSet(0);
private Set projectmodel = new HashSet(0);

public Integer getId() {
    return this.id;
}

public void setId(Integer id) {
    this.id = id;
}

public Set<Modelpst> getModelpsts() {
    return this.modelpsts;
}

public void setModelpsts(Set<Modelpst> modelpsts) {
    this.modelpsts = modelpsts;
}

public Set<ProjectModel> getProjectmodel() {
    return projectmodel;
}

public void setProjectmodel(Set<ProjectModel> projectmodel) {
    this.projectmodel = projectmodel;
}

}
[/code]

[b]Models.hbm.xml[/b]
[code="xml"]
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">






models_seq
















[/code]