首页 > 移动平台 > 详细

The method load(Class, Serializable) in the type Session is not applicable for the arguments (Class<

时间:2015-02-27 18:29:05      阅读:1866      评论:0      收藏:0      [点我收藏+]

    Transaction transaction = session.beginTransaction(); 
//load是通过主键属性,获取对象的实例
Employee employee  =(Employee) session.load(Employee.class, 1);
         employee.setName("demo");
         transaction.commit();
         session.close();

报错The method load(Class, Serializable) in the type Session is not applicable for the arguments (Class<T>, int)

myeclipse明显的报错,这说明在myeclipse中jdk的自动拆装箱没有自动完成,但我的jdk用的是java8的。

使用

    Transaction transaction = session.beginTransaction(); 
//load是通过主键属性,获取对象的实例
 Employee employee  =(Employee) session.load(Employee.class, new Integer(1));
         employee.setName("demo");
         transaction.commit();
         session.close();

就行了,网上找了下,发现这应该是hibernate版本的问题,在hibernate中的操作,要看你引用的hibernate版本本身是否支持自动拆装。

应该是hibernate本身不允许这么做,所以才必须要写成对象类型才能进行查询,这和jdk已经无关了。

The method load(Class, Serializable) in the type Session is not applicable for the arguments (Class<

原文:http://blog.csdn.net/qq_20545159/article/details/43969837

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!