The method load(Class, Serializable) in the type Session is not applicable for the arguments (Class<
2015-02-27 16:59
603 查看
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已经无关了。
//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 setClass(Context, Class<?>) in the type Intent is not applicable for the arguments (GameV
- he method get(Class, Serializable) in the type HibernateTemplate is not applicable for the arguments
- The method setClass(Context, Class<?>) in the type Intent is not applicable for the arguments (GameV
- The method setClass(Context, Class<?>) in the type Intent is not applicable for the问题
- The method add(Fragment) in the type ArrayList<Fragment> is not applicable for the arguments (ImageF
- 关于The method setMapperClass(Class<? extends Mapper>) in the type Job is not applicable for the argum
- The method setValue(String) in the type ParamTag is not applicable for the arguments (long)
- The method setItems(String) in the type ForTokensTag is not applicable for the arguments (Object)
- OSCache的源码编译Cache.java 文件报add(Class, T) in the type EventListenerList is not applicable for the arguments 错误的解决
- The method create(Context, Uri) in the type MediaPlayer is not applicable for the arguments (new Vie
- 错误:The method replace(int, Fragment) in the type FragmentTransaction is not applicable for the arguments (int, MyFragment)
- The method setBackground(Drawable) in the type View is not applicable for the arguments (int)
- [真理永垂不朽]The method XXX in the type FragmentTransaction is not applicable for the arguments XXX
- The method add(int, Fragment) in the type FragmentTransaction is not applicable for the arguments (i
- The method sendKeys(CharSequence[]) in the type WebElement is not applicable for the arguments (String)
- The method setPositiveButton(int, DialogInterface.OnClickListener) in the type AlertDialog.Builder is not applicable for the arguments
- The method setStatus(int) in the type Goods is not applicable for the arguments (Integer)
- The method replace(int, Fragment, String) in the type FragmentTransaction is not applicable for the arguments (int, SettingFragment, String)
- The method makeText(Context, int, int) in the type Toast is not applicable for the arguments (new Vi
- 错误:The method replace(int, Fragment) in the type FragmentTransaction is not applicable for the argum