日期:2014-05-18  浏览次数:20723 次

hibernate联合主键的问题
表结构如下:
A : studentId, contentId,sex; studentId和contentId是联合主键;
B : courseId, roomId,contentId,courseId和roomId是联合主键,其中contentId是外键,参照A表。
Table A---->ABean
Table B---->BBean

hibernate的bean的config.xml中 compositeKey我已经完成配置,但是现在遇到的问题是:在DAO中调用(ABean)this.session.get(ABean.class,parameter)的时候总是报illegalArgumentException:object is not an instance of declaring class
请问各位大侠联合主键用hql直接获取对象的时候,并且带有one-to-many的情况,如何在DAO中处理compositeKey?

给出思路即可。

------解决方案--------------------
直接new一个compositeKey,给属性赋上值,把这个compositeKey,set到实体类中,就行了。。。