日期:2014-05-17  浏览次数:20616 次

hibernate多对多映射中间表如何加入其它字段?
如题:
Student表:
sid、sname

Course表:
cid、cname

中间表SC:
sid(Student表外键)、cid(Course表外键)、score(学生分数)

使用多对多如何能保存score字段值?

我在网上看到有人说用两个多对一,将中间表SC也用类封装。请问大家都是这么做的么?还是有更好的方法?

------解决方案--------------------
在使用Hibrenate的时候,Sc实体中应该包含student和Course实体,所以西安封装student和Course实体,然后封装Sc实体,最后保存应该就可以了