hibernate 中 Provided id of the wrong type for class 异常
2017-11-20 17:04
465 查看
今天在工作中遇到了一个问题,在hibernate的使用过程中抛出了个异常:
收集资料后发现:在HibernateTemplate中的get方法仅仅可以查找主键,不可以查找其他字段。其实是自己没有考虑好,在开始的时候自己还有过这样的疑问:get来查找是怎么对应字段,而且查找出来只是单个的,并不是个List。但是没有多想,现在用get来查找其他字段就抛出了了这个异常。
其实看到这个异常就可以知道,肯定是类型错误,像我这个就是String类型转int类型了(在使用get方法中)。
所以,检查一下类型匹配就可以解决了,包括是不是也用get方法查找其他字段了(其实也是类型匹配的问题)。
HTTP Status 500 - Provided id of the wrong type for class com.s_football.pojo.UserBean. Expected: class java.lang.Integer, got class java.lang.String; nested exception is org.hibernate.TypeMismatchException: Provided id of the wrong type for class com.s_football.pojo.UserBean. Expected: class java.lang.Integer, got class java.lang.String
收集资料后发现:在HibernateTemplate中的get方法仅仅可以查找主键,不可以查找其他字段。其实是自己没有考虑好,在开始的时候自己还有过这样的疑问:get来查找是怎么对应字段,而且查找出来只是单个的,并不是个List。但是没有多想,现在用get来查找其他字段就抛出了了这个异常。
其实看到这个异常就可以知道,肯定是类型错误,像我这个就是String类型转int类型了(在使用get方法中)。
所以,检查一下类型匹配就可以解决了,包括是不是也用get方法查找其他字段了(其实也是类型匹配的问题)。
相关文章推荐
- Hibernate异常:Provided id of the wrong type for class
- hibernate.TypeMismatchException: Provided id of the wrong type for class
- hibernate 错误:Provided id of the wrong type for class com.lhaix.pojo.Test. Expected: class java.la
- org.hibernate.TypeMismatchException: Provided id of the wrong type for class
- Provided id of the wrong type for class pojo.Books. Expected: class java.lang.Integer, got class java.lang.Long
- Provided id of the wrong type for class
- SSH报错之 Provided id of the wrong type for class model.User. Expected: class java.lang
- TypeMismatchException: Provided id of the wrong type for class zhongfucheng.user.entity.User.
- Caused by: org.hibernate.TypeMismatchException: Provided id of the wrong type. Expected: class java.lang.Integer, got class [Lja
- TypeMismatchException: Provided id of the wrong type for class zhongfucheng.user.entity.User.
- Exception in thread "main" org.hibernate.TypeMismatchException: Provided id of the wrong type
- org.hibernate.WrongClassException: Object with id: 3 was not of the specified subclass
- "org.xml.sax.SAXParseException: The content of element type "class" must match" 异常解决
- he method get(Class, Serializable) in the type HibernateTemplate is not applicable for the arguments
- 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`.
- 关于hibernate中报错”The content of element type "class" must match ......“的一点发现
- 对The method createBlob() is undefined for the type Hibernate异常的解决办法
- This error is raised because the column 'type' is reserved for storing the class in case of inheritance
- The serializable class XXXAcion does not declare a static final serialVersionUID field of type long XXAcation.java异常坚决办法
- 异常:There was no TypeHandler found for parameter id of statement