I am biginner for Hibernate. I create one POJO MyUsers.java, MyUsersTest.java program to run, a table myusers in MySql also one mapping file MyUsers.hbm.xml & hibernate.proprties and all placed in src folder of the application. But when i tried to run the program file MyUsersTest.java i am getting error mentioning
Configuration cannot be resolved to a type Configuration cannot be resolved to a type Sessionfactory cannot be resolved to a type Session cannot be resolved to a type
Please let me know why i am gettign this error. Where i am going wrong? Please help to solve the problem.
Object config; Class SessionFactory = ((Object)config).getClass(); Session session = SessionFactory.openSession();
You are calling the openSession method on a object of type Class, which is incorrect. Class does not have any such methods available on it. Have a look at Hibernate Reference to see how the SessionFactory can be configured.
Exception in thread "main" java.lang.Error: Unresolved compilation problems: Cannot make a static reference to the non-static method close() from the type SessionFactory Type mismatch: cannot convert from void to Object
Its just as the error says - you are trying to assign the return value of the SessionFactory's close() method to an Object when the method's return type is void and you are calling the method as if it were a static method which it is not.