hibernate 错误:Provided id of the wrong type for class com.lhaix.pojo.Test. Expected: class java.la
2013-10-31 19:57
567 查看
hibernate 错误:Provided id of the wrong type for class com.lhaix.pojo.Test. Expected: class java.la
错误:Provided id of the wrong type for class com.lhaix.pojo.Test. Expected: class java.lang.Long, got class java.lang.Integer
原因是传入的是Integer类型的参数,它需要的是Long类型的参数。
在Hibernate里,只要Number(8)以上的都是用Long类型。
我的代码是:Test test = (Test)session.get(Test.class, 1);
这么写传的是Integer。
应该这么写:Test test = (Test)session.get(Test.class, 1L);
或者:Test test = (Test)session.get(Test.class, (long)1);
等等写法
转自: http://hi.baidu.com/lhaix/item/067d570a2b625adf73e676ea
错误:Provided id of the wrong type for class com.lhaix.pojo.Test. Expected: class java.lang.Long, got class java.lang.Integer
原因是传入的是Integer类型的参数,它需要的是Long类型的参数。
在Hibernate里,只要Number(8)以上的都是用Long类型。
我的代码是:Test test = (Test)session.get(Test.class, 1);
这么写传的是Integer。
应该这么写:Test test = (Test)session.get(Test.class, 1L);
或者:Test test = (Test)session.get(Test.class, (long)1);
等等写法
转自: http://hi.baidu.com/lhaix/item/067d570a2b625adf73e676ea
相关文章推荐
- Provided id of the wrong type for class pojo.Books. Expected: class java.lang.Integer, got class java.lang.Long
- Caused by: org.hibernate.TypeMismatchException: Provided id of the wrong type. Expected: class java.lang.Integer, got class [Lja
- SSH报错之 Provided id of the wrong type for class model.User. Expected: class java.lang
- hibernate 中 Provided id of the wrong type for class 异常
- Hibernate异常:Provided id of the wrong type for class
- org.hibernate.TypeMismatchException: Provided id of the wrong type for class
- hibernate.TypeMismatchException: Provided id of the wrong type for class
- TypeMismatchException: Provided id of the wrong type for class zhongfucheng.user.entity.User.
- TypeMismatchException: Provided id of the wrong type for class zhongfucheng.user.entity.User.
- Provided id of the wrong type for class
- Exception in thread "main" org.hibernate.TypeMismatchException: Provided id of the wrong type
- No converter found for return value of type: class com.taotao.pojo.TbItem
- java编译错误No enclosing instance of type TestFrame is accessible. Must qualify the allocation with an enclosing instance of type TestFrame (e.g. x.new A(
- java.lang.IllegalStateException: Driver for test database type [H2] is not available in the classpat
- ReactJs 报错 Element type is invalid: expected a string (from built-in components) or a class/function (for composite components) but got: undefined. Check the render method of `Me`.
- Java Web编程入门--错误信息“The method getUserById(int) of type UserServiceImpl must override a superclass”
- org.hibernate.WrongClassException: Object with id: 3 was not of the specified subclass
- hibernate:newclass.hbm.xml文件错误(the content of element type "class" must match "(meta*,column*,type?generator?...)
- OSCache的源码编译Cache.java 文件报add(Class, T) in the type EventListenerList is not applicable for the arguments 错误的解决
- JSP出现的错误为java cannot find the tag library descriptor for "http://java.sun.com/jsp/jstl/core"