Using resource mapping
As you are using a mapping resource, the problem is with class path mentioned in your emp.hbm.xml
, as you have Employee.java
inside the package hibernatetutorial1
your class path will be hibernatetutorial1.Employee
. So you need to mention this in your emp.hbm.xml
//emp.hbm.xml
<hibernate-mapping>
<class name="hibernatetutorial1.Employee" table="tablename">
.......
.......
</hibernate-mapping>
and map this resource inside Hibernate.cfg.xml
//Hibernate.cfg.xml
<hibernate-configuration>
<session-factory>
......
......
......
<mapping resource="emp.hbm.xml"/>
</session-factory>
</hibernate-configuration>
Using annotated class mapping
It's better using annotated classes as they decrease your burden, if you are using annotated class then you need to mention your classpath inside Hibernate.cfg.xml
and you need to use mapping class, no need of mapping resource
//using annotated class mapping no need of emp.hbm.xml(resource mapping)
//Hibernate.cfg.xml
<hibernate-configuration>
<session-factory>
......
......
......
<mapping class="hibernatetutorial1.Employee"/>
</session-factory>
</hibernate-configuration>