请教个问题,hibernate中如果Student类跟Course类是这样的关系:
class Student
{
Set<Course> goodCourseSet;
Set<Course> badCourseSet;
}
这时hbm中的一对多关系该怎么写啊?谢谢!
class Student
{
Set<Course> goodCourseSet;
Set<Course> badCourseSet;
}
这时hbm中的一对多关系该怎么写啊?谢谢!
解决方案 »
- EJB3 中 为了实现多个定时器,这样对吗?
- js计算时间差 年、月、日
- ORA-01722:无效数字
- hibernate配置双主键
- 急~~~~!!!!!在Eclipse中连接SQL2000就是连接不上!!!
- 本机IP和localhost有区别吗,大家都来帮忙看看,UP有分,谢谢~
- Ajax与JSF的关系是什么,他是不是JSF框架的实现?
- 求助 请教 socket挂死
- 怎么用java.util.regex包中的类来进行全字匹配替换操作?
- 这个为何?txt文件中,把三级目录以上的去除掉,留下的保存在另外一个文档。
- 学了strust2 hibernate spring 能找工作吗
- 关于 poi操作excel文档异常 求各位经验之士帮顶
</many-to-one>
<many-to-one class="eai.module.basicsettings.entity.BsProduct" fetch="select" name="bsProduct">
<column name="productId" />
???
我的问题重点在于一个Student对应了两个Course集,如果只是对应一个Course集,写hbm文件是很简单的,在底层数据库表Course里面加一列StudentID属性就可以了,但现在Student对应了两个Course集,仅仅加一列StudentID属性肯定已经区分不出来到底对应哪个Course集了,所以底层表结构要变,这样hbm文件肯定也要变,但我不知该怎么变
<key column="student_id"/>
<many-to-many class="Course"/>
</set>
<set name= "goodCourseSet" >
<key >
<column name= "student_id" />
<column name= "isGood" value="1" />
</key>
<one-to-many class= "Course"/>
</set>
<set name= "goodCourseSet" >
<key >
<column name= "student_id" />
<column name= "isGood" value="0" />
</key>
<one-to-many class= "Course"/>
</set>
class Student
{
private List<Course> goodCourses;
private List<Course> badCourses;@OneToMany
public getGoodCourses()
{
return goodCourese
}
}
http://docs.jboss.org/hibernate/annotations/3.5/reference/en/html_single/#entityBTW,我了解过一些Hibernate~
<key>
<column name="ft_id" />
</key>
<one-to-many class="com.list.pojo.MemberFoodInfo" />
</set>这是个例子 自己对照看一下