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 ...
随机推荐
- 潭州课堂25班:Ph201805201 python 模块 datetime,logging 第七课 (课堂笔记)
datetime 模块 # -*- coding: utf-8 -*-# 斌彬电脑# @Time : 2018/7/9 0009 20:42import datetime d = datetime.d ...
- 潭州课堂25班:Ph201805201 第十五课 迭代器,生成器 (课堂笔记)
推导表达式 li1 = list() for i in range(10): # 迭代循环内容 li1.append(i) print( li1 ) ---->>> [0, 1, 2 ...
- [HDU4906]Our happy ending
[HDU4906]Our happy ending 题目大意: 让你构造一个\(n(n\le20)\)个数的数列,其中每个数都为小于等于\(l(l\le10^9)\)的非负整数. 问你能构造出多少个这 ...
- 2017-2018-2 1723 『Java程序设计』课程 结对编程练习_四则运算第三周总结
相关测试过程截图 测试了由中缀表达式转后缀表达式的Junit测试,分别进行了整数的和分数的,测试成功截图 由于生成问题和计算问题中,问题都是随机产生的,暂时不会进行Junit测试,故没有进行,但应是正 ...
- GitLab 安装(推荐)
参考文档: https://about.gitlab.com/installation/#centos-7 基础环境 [root@node1 ~]# uname -r -.el7.x86_64 [ro ...
- poj 1184
经典的宽搜题目,感觉最好的办法应该是双向广搜. 不过用简单的启发式搜索可以飘过. #include <iostream> #include <cstdio> #include ...
- Linux centOS Ubuntu --- 使用systemctl添加开机启动
我们对service和chkconfig两个命令都不陌生,systemctl 是管制服务的主要工具, 它整合了chkconfig 与 service功能于一体. systemctl is-enable ...
- Go语言之高级篇beego框架之Controller
一.Controller 控制器 Controller等同于Django里的view,处理逻辑都是在Controller里面完成的,下面就写一个最简单的Controller.写controller的时 ...
- 用.Net打造一个移动客户端(Android/IOS)的服务端框架NHM(四)——Android端Http访问类(转)
本章目的 在上一章中,我们利用Hibernate Tools完成了Android Model层的建立,依赖Hibernate Tools的强大功能,自动生成了Model层.在本章,我们将继续我们的项目 ...
- escape()、encodeURI()、encodeURIComponent()区别详解 (转)
JavaScript中有三个可以对字符串编码的函数,分别是: escape,encodeURI,encodeURIComponent,相应3个解码函数:,decodeURI,decodeURIComp ...