首页 > 编程语言 > 详细

org.hibernate.TypeMismatchException: Provided id of the wrong type for class cn.itcast.entity.User. Expected: class java.lang.String, got class java.lang.Integer at org.hibernate.event.internal.Defau

时间:2018-11-06 21:10:24      阅读:417      评论:0      收藏:0      [点我收藏+]

出现org.hibernate.TypeMismatchException: Provided id of the wrong type for class cn.itcast.entity.User. Expected: class java.lang.String, got class java.lang.Integer at org.hibernate.event.internal.DefaultLoadEventListener.checkIdClass(DefaultLoadEventListen

这样的错误,可能是bean中的数据类型和hbm.xml中指定的主键生成策略不一致。

比如我在bean中,将uid写出字符串,而在hbm.xml中使用的是<generator class="native"/>这样就报错了。

org.hibernate.TypeMismatchException: Provided id of the wrong type for class cn.itcast.entity.User. Expected: class java.lang.String, got class java.lang.Integer at org.hibernate.event.internal.Defau

原文:https://www.cnblogs.com/liaoxiaolao/p/9918050.html

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