Log4j:warn No Appenders could is found for logger (org.hibernate.cfg.Environment).
Log4j:warn 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)
Create a database with an ID of int
CREATE table for database: CREATE TABLE books (ID INT PRIMARY KEY auto_increment,bookname varchar (), Bookprice varchar (40));
Books Bookfirst = (Books) session.get (Books.class, New Long (1));
This is because the database ID does not match the integer with the long type data!
Modified. Hbm.xml
Modify primary key data type to long
Provided ID of the wrong type for class Pojo. Books. Expected:class Java.lang.Integer, got class Java.lang.Long