Consider the hierarchy :
And the following classes and xml :
I was having similar issue and adding
sessionFactory.setAnnotatedClasses(User.class);
this line helped but before that I was having
sessionFactory.setPackagesToScan(new String[] { "com.rg.spring.model" });
I am not sure why that one is not working.User class is under com.rg.spring.model Please let me know how to get it working via packagesToScan method.