Hibernate and MappingNotFoundException

I use Netbeans IDE.My hibernate.cfg.xml looks like this:\[code\]<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"><hibernate-configuration> <session-factory> //properties <mapping resource="entities.Employee"/> <mapping resource="entities.Human"/> </session-factory></hibernate-configuration>\[/code\]And hibernate.cfg.xml is in \[code\]NetBeansProjects\HibernateTest\build\web\WEB-INF\classes\\[/code\]My code to initialize SessionFactory looks like this:\[code\]static { try { String configFilePath = "/hibernate.cfg.xml"; URL configFileURL = SessionFactory.class.getResource(configFilePath); sessionFactory = new Configuration().configure(configFileURL).buildSessionFactory(); } catch (Throwable ex) { // Log the exception. throw new RuntimeException(ex); }}\[/code\]and entites (Employee.class and Human.class) is in \[code\]\NetBeansProjects\HibernateTest\build\web\WEB-INF\classes\entities\\[/code\]Class Employee:\[code\]/* * To change this template, choose Tools | Templates * and open the template in the editor. */package entities;import java.io.Serializable;import javax.persistence.*;@Entity@Table(name = "EMPLOYEE")public class Employee implements Serializable { public Employee(){ } @Id @GeneratedValue(strategy = GenerationType.TABLE) @Column(name = "EMPLOYEE_ID") private int employeeId; @Column(name = "SALARY") private double salary; @OneToOne(cascade = CascadeType.ALL, fetch= FetchType.LAZY) @PrimaryKeyJoinColumn private Human humDate; public int getEmployeeId() { return employeeId; } public void setEmployeeId(int employeeId) { this.employeeId = employeeId; } public Human getHumDate() { return humDate; } public void setHumDate(Human humDate) { this.humDate = humDate; } public double getSalary() { return salary; } public void setSalary(double salary) { this.salary = salary; }}\[/code\]Class human:\[code\]/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package entities; import java.io.Serializable; import javax.persistence.*; @Entity @Table(name = "HUMAN") public class Human implements Serializable { public Human(){ } public Human(String name){ this.name = name; } private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy = GenerationType.TABLE) private int id; @Column(name = "HUM_NAME") private String name; public String getName() { return name; } public void setName(String name) { this.name = name; } public int getId() { return id; } public void setId(int id) { this.id = id; } @Override public int hashCode() { int hash = 0; hash += (int) id; return hash; } @Override public boolean equals(Object object) { // TODO: Warning - this method won't work in the case the id fields are not set if (!(object instanceof Human)) { return false; } Human other = (Human) object; if (this.id != other.id) { return false; } return true; } @Override public String toString() { return "com.nsn.Human[ id=" + id + " ]"; } }\[/code\]What's wrong here?
 
Back
Top