进行CRUD出现以下异常
- org.hibernate.TypeMismatchException: Provided id of the wrong type for class org.liyy.model.Shop_books_group. Expected: class java.lang.String, got class java.lang.Integer
- org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:135)
- org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:1090)
- org.hibernate.impl.SessionImpl.get(SessionImpl.java:1005)
- org.hibernate.impl.SessionImpl.get(SessionImpl.java:998)
- sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
- sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
- sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
- java.lang.reflect.Method.invoke(Method.java:597)
- org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:344)
- $Proxy12.get(Unknown Source)
- org.liyy.base.Base.findById(Base.java:98)
- org.liyy.page.action.CartAction.addCart_db(CartAction.java:203)
- org.liyy.page.action.CartAction.addCart(CartAction.java:42)
- sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
- sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
- sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
- java.lang.reflect.Method.invoke(Method.java:597)
原因是:实体类中主键的类型设置和数据库中不匹配。
解决方法:
1.查看实体类中主键的类型。
2.查看数据库中主键设置的类型。
3.统一类型即可解决
分享到:
相关推荐
MyEclipse+hibernate错误:Could not get list of suggested identity strategies from database解决
Hibernate学习:单向多对一关联 工程
Get started with the Hibernate 5 persistence layer and gain a clear introduction to the current standard for object-relational persistence in Java. This updated edition includes the new Hibernate 5.0 ...
hibernate 入门:10分钟跑起这个hibernate 示例程序 (图解、附源码http://download.csdn.net/source/650851)
精通Hibernate:Java对象持久化技术详解.pdf 精通Hibernate:Java对象持久化技术详解.pdf
操作Hibernate类:增加,删除,修改及查询.pdf
内容:hibernate001:通过 XML 配置的基本示例 hibernate002:通过注释配置的基本示例 hibernate003:会话方法练习 hibernate004:组件使用示例 hibernate005:单向关系映射示例 hibernate006:双向关系映射示例 ...
精通Hibernate:Java对象持久化详解解压后是pdf文档。
平台依赖度低的解决方案 ...测试环境:equinox3.5.2。其它用到的Bundle包括hibernate、hibernate-annotation、hsqldb、 spring、spring-osgi等。请到http://www.springsource.com/repository/下载。
官网hibernate:问题说明: 1、安装整合通过; 2、整合时注意javassist-3.22.0-GA.jar与struts2.4的 javassist-3.20.0-GA.jar重复; 3、整合所需基础包以及整合需要的外部包,自己放到一个新建文件夹中,方便大家...
博文链接:https://llying.iteye.com/blog/221699
Get started with the Hibernate 5 persistence layer and gain a clear introduction to the current standard for object-relational persistence in Java. This updated edition includes the new Hibernate 5.0 ...
hibernate 常见异常非常不错的,hibernate 常见异常非常不错的
No Hibernate Session bound to thread,没有绑定线程解决办法,找了好久才找到的
本系统是学习开源框架hibernate的绝好材料,通过其可以迅速领悟hibernate的精髓。
一共有三个分卷。全部下载才能解压。 这本书不错,值得一看。
NULL 博文链接:https://xiaoxuesheng.iteye.com/blog/2107997
Hibernate是一个开放源代码的对象关系映射框架,它对 JDBC进行了非常轻量级的对象封装,它将POJO类与数据库表建立映射关系,是一个全自动的ORM框架,hibernate可以自动生成SQL语句,自动执行。Hibernate可以应用在...
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/...
精通Hibernate:Java对象持久化技术详解(第2版)源码精通Hibernate:Java对象持久化技术详解(第2版)源码