I\'ve got a really simple class:
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.pers
Add to hibernate.cfg.xml before </session-factory> this:
<mapping class="org.assessme.com.entity.User" />
You should use AnnotationConfiguration instead of Configuration and then call
configuration.addAnnotatedClass(User.class);
to add your class to the list of mapped classes.
Add below line to your hibernate.cfg.xml
<mapping class="fully qualified Entity class name"/>
I forgot to add the hbm.xml mapping into my cfg.xml file. As soon as I added it, this exception disappeared.
<mapping resource="com/mycompany/backend/hibernate/CServiceCenters.hbm.xml" />
Consider using AnnotationConfiguration described here.
You could either use its addClass(User.class) method, or if you're persisting multiple entities use the addPackage("org.assessme.com.entity") method.
You're kind of reinventing the wheel with this HibernateUtil class. Consider using Spring so you can leverage something like its AnnotationSessionFactoryBean.
Do you have any persistence.xml or hibernate.cfg.xml? If you have to add your mapping class in it so hibernate get understand your class is mapping to the database. If you have hibernate.cfg.xml you can add like this
<mapping class="com.entity.Users"/>