The method get(Class, Serializable)

来源:百度知道 编辑:UC知道 时间:2024/05/30 07:45:17
The method get(Class, Serializable) in the type HibernateTemplate is not applicable for the arguments (Class, int)

--这个是我方法中的返回值
return (Job)this.getHibernateTemplate().get(Job.class, id);

其中 ID是 INT 型的 但是 貌似 它让我 变成
Serializable 类型 但是 老师 的也是这个 方法 照老师的敲的 请问 我是哪地方出错了 ?
郁闷了 JRE 换成1.5的 就好了 。。。谁 来 随便说继续 我给 评下~

可能是JDK版本问题,你改一下最新的版本,如果不行的话,就这样写:
User user = (User)session.get(User.class, new Integer(id));

换成1.5之后,int会自动包装成Integer类型的,而Integer实现了Serializable接口