HIbernate 3.2 java.lang.IllegalArgumentException: object is not an instance of declaring class

来源:互联网 发布:创意广告知乎 编辑:程序博客网 时间:2024/05/29 05:53

1. 用select count(id) from table_a ; 返回的记录数必须Long类型,不然出错
2. 在读取记录中的HQL,参数必须匹配,不然出错
例如:
表:table_a  ,table_b
主键类型都是String id;

table_a   多对1table_b

根据table_b的Id来查询table_a里面的记录,hql如下
from table_a  A  Where A.b = ? ;

此时在传入?的参数必须是一个table_b类的实例,不能是一个String类型的id

在hibernate 3.2之前的版本用String类型的id是不会出错的。
 

原创粉丝点击