Provided id of the wrong type for class pojo.Books. Expected: class java.lang.Integer, got class jav
Posted xiaobo-linux
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Provided id of the wrong type for class pojo.Books. Expected: class java.lang.Integer, got class jav相关的知识,希望对你有一定的参考价值。
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 jav的主要内容,如果未能解决你的问题,请参考以下文章
Unalignable boolean Series provided as indexer (index of the boolean Series and of the indexed objec
WRONGTYPE Operation against a key holding the wrong kind of value
redis 报Operation against a key holding the wrong kind of value警告的解决方法
Redis发生异常WRONGTYPE Operation against a key holding the wrong kind of value
Could not find a package configuration file provided by “gazebo“ with any of the following names:
Redis报错:ERR Operation against a key holding the wrong kind of value 解决处理