Provided id of the wrong type for class pojo.Books. Expected: class java.lang.Integer, got class java.lang.Long
log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" org.hibernate.TypeMismatchException: Provided id of the wrong type for class pojo.Books. Expected: class java.lang.Integer, got class java.lang.Long
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:109)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:906)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:843)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:836)
at test.test.sessions(test.java:34)
at test.test.main(test.java:55)
创建数据库,id 为int
创建数据库的表:CREATE TABLE books(id INT PRIMARY KEY auto_increment,Bookname VARCHAR(50),Bookprice VARCHAR(40));
Books bookFirst = (Books)session.get(Books.class, new Long(1));
这是因为 数据库id为integer与long类型数据不匹配!
修改.hbm.xml
修改主键数据类型为long
Provided id of the wrong type for class pojo.Books. Expected: class java.lang.Integer, got class java.lang.Long的更多相关文章
- TypeMismatchException: Provided id of the wrong type for class zhongfucheng.user.entity.User.
今天在使用SSH框架做项目的时候出现了这个错误,找了我非常非常多的时间!!!!!!! Struts Problem Report Struts has detected an unhandled ex ...
- 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
出现org.hibernate.TypeMismatchException: Provided id of the wrong type for class cn.itcast.entity.User ...
- org.hibernate.TypeMismatchException: Provided id of the wrong type for class *** Expected ***
今天上生产发现warn日志有异常,就查看了下: 2018-12-05 10:05:05.666 [pool-4-thread-1] ERROR org.springframework.batch.co ...
- Cannot convert 0 of type class java.lang.Integer to class java.lang.Boolean
org.apache.catalina.core.ApplicationDispatcher invoke SEVERE: Servlet.service() for servlet jsp thre ...
- iOS Assigning to 'id<XXXDelegate>' from incompatible type 'BViewController *__strong'
在使用代理的时候, BViewController *BVC = [[BViewController alloc]init]; self.delegate = BVC; 出现这样的警告Assignin ...
- JSP页面使用EL表达式出现的问题:javax.el.PropertyNotFoundException: Property 'ID' not found on type java.lang.Str
问题描述: 1. 后台返回到JSP前台的的list,在jsp页面使用EL表达式遍历时出现如下问题:javax.el.PropertyNotFoundException: Property 'ID' n ...
- java 反射 报错:Attempt to get java.lang.Integer field "..." with illegal data type conversion to int
类: Integer id; 反射时: Field f = User.class.getDeclaredField("id"); f.setAccessible(true); in ...
- org.springframework.dao.InvalidDataAccessApiUsageException: Parameter value [41] did not match expected type [java.lang.Integer (n/a)];
题记:以前记录过一些自己遇到的BUG,这个行为,让我一看报错的提示信息就能定位到问题的所在,后来记得比较多了,好多是重复性的再加上比较忙就没有详细的记录了,今天的工作量比较小,就顺便记录一下,以便以后 ...
- no suitable HttpMessageConverter found for request type [java.lang.Integer]
今天在使用Spring Template的时候遇到了这个异常: no suitable HttpMessageConverter found for request type [java.lang.I ...
随机推荐
- 网络名词拾遗--part2
网络名词拾遗--part2 关于所谓的连接上限 先要明白服务端和客户端的交互逻辑: 服务端创建socket 与提供对外服务的port端口绑定 开始监听 客户端向这个端口提出请求 服务端接收到这个请求后 ...
- 关于Mysql安装启动的若干问题解决
Mysql由于其免费,高效的特点一直是大学,培训班的主力数据库管理软件.但是对于初学者而言可能没有那么友好,一是没有windows软件通用的那套可视化操作,基本上初期在不搭配navicat的状态下只能 ...
- python 数字
python数字: 本文主要讲解常用的数字类型转换, 数字函数和随机数字函数. # coding:utf-8 # python数字类型转换 def data_conversion(): "& ...
- (58)Wangdao.com第九天_JavaScript 对象的基本操作
对象的基本操作 创建对象 var 对象名 = new Object(); // new 函数; 称为构造函数,专门用来创建对象的函数 var god = 给对象增加属性 删除对象 ...
- Maven学习总结(11)——Maven Tomcat7自动部署
1.配置tomcat-users.xml文件 在tomcat安装目录下找到tomcat-users.xml文件.该文件路径为[tomcat安装根目录]/conf/ 修改文件内容,增加下列内容: < ...
- SpringMvc+Mybatis+Maven+Mysql做一个CRUD的简单例子
本文档结合 SpringMVC. Mybatis. MySQL,说明如何实现一个简单的数据库单表 CRUD操作.开发工具使用集成了spring mvc的eclipse(Spring Tool Suit ...
- Knockout.Js官网学习(selectedOptions绑定、uniqueName 绑定)
selectedOptions绑定 selectedOptions绑定用于控制multi-select列表已经被选择的元素,用在使用options绑定的<select>元素上. 当用户在m ...
- 出现System.web.mvc冲突的原因及解决方法CS0433
1.问题描述 CS0433:类型“System.Web.Mvc.WebViewPage<TModel>”同时存在于URL1和URL2中 2.解决方案 找到Web.config文件中的< ...
- 开发指南专题五:JEECG微云高速开发平台代码生成器
开发指南专题五:JEECG微云高速开发平台代码生成器 1.1. Maven开发环境搭建 在搭建jeecg的maven开发环境之前,须要先配置好本机的maven环境,并在eclipse中安装好m2ecl ...
- javascript arguments介绍
来源于: https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Functions/arguments https://g ...