Q:

unable to map second class : ** org.hibernate.MappingException: An association from the table employee refers to an unmapped class**

I'm working with code in which I'm unable to map other class as I've two classes and this code with one class works fine , am I doing it wrong please check the code:
department.hbm.xml
 <hibernate-mapping>
        <class name="com.java.commons.Department" table="department">
            <id name="id" column="id">
                <generator class="assigned" />
            </id>

            <property name="deptName" column="deptName" />
        </class>
    </hibernate-mapping>

employee.hbm.xml
<hibernate-mapping>
    <class name="com.java.commons.Employee" table="employee">
        <id name="id" column="id" type="long">
            <generator class="identity" />
        </id>
        <property name="firstName" type="String" column="firstName" />
        <property name="salary" column="salary" />
        <many-to-one name="department" class="Department" column="department" />
    </class>
</hibernate-mapping>

and connection.cfg.xml
<hibernate-configuration>
    <session-factory>
        <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
        <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
        <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/justhibernate</property>
        <property name="hibernate.connection.username">root</property>
        <property name="hibernate.connection.password">root</property>
        <property name="hibernate.show_sql">true</property>
        <property name="hibernate.hbm2ddl.auto">create</property>
        <property name="hibernate.order_inserts">true</property>
        <property name="hibernate.order_updates">true</property>
        <property name="hibernate.jdbc.batch_size">2</property>

        <mapping resource="employee.hbm.xml" />
        <mapping resource="department.hbm.xml" />

    </session-factory>

</hibernate-configuration>

connection.java
public static SessionFactory buldSessionFactory() {
        SessionFactory sessionFactory = null;
        try {
            sessionFactory = new Configuration().configure("connection.cfg.xml").addResource("department.hbm.xml")
                    .addResource("employee.hbm.xml").buildSessionFactory();
            System.out.println("session Factory created");
        } catch (Throwable ex) {
            System.err.println("Session Factory creation Failed  " + ex);
            throw new ExceptionInInitializerError(ex);
        }
        return sessionFactory;

    }

error log
Session Factory creation Failed  org.hibernate.MappingException: An association from the table employee refers to an unmapped class: Department
Exception in thread "main" java.lang.ExceptionInInitializerError
    at com.java.commons.HibernateUtil.buldSessionFactory(HibernateUtil.java:16)
    at com.java.save_data.SavingData.savingData(SavingData.java:9)
    at com.java.save_data.SavingData.main(SavingData.java:15)
Caused by: org.hibernate.MappingException: An association from the table employee refers to an unmapped class: Department
    at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.secondPassCompileForeignKeys(InFlightMetadataCollectorImpl.java:1838)
    at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.secondPassCompileForeignKeys(InFlightMetadataCollectorImpl.java:1809)
    at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.processSecondPasses(InFlightMetadataCollectorImpl.java:1627)
    at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:278)
    at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.build(MetadataBuildingProcess.java:83)
    at org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:418)
    at org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:87)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:692)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:724)
    at com.java.commons.HibernateUtil.buldSessionFactory(HibernateUtil.java:12)
    ... 2 more

Employee.java
public class Employee {

    private long id;
    private String firstName;
    private String salary;
    private Department department;

    public Employee() {
    }

    public Employee(String firstName, String salary, Department department) {
        this.firstName = firstName;
        this.salary = salary;
        this.department = department;
    }

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    public String getSalary() {
        return salary;
    }

    public void setSalary(String salary) {
        this.salary = salary;
    }

    public Department getDepartment() {
        return department;
    }

    public void setDepartment(Department department) {
        this.department = department;
    }
}

department.java
public class Department {
    private long id;
    private String deptName;

    public Department() {
    }

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public String getDeptName() {
        return deptName;
    }

    public void setDeptName(String deptName) {
        this.deptName = deptName;
    }

    public Department(String deptName) {
        this.deptName = deptName;
    }

}

error log says employee is mapped to non mapped class Department why? and how to fix when one is working with more then two classes ...
any help will be appreciated
Regards and Thanks.

A:

Use fully qualified class name 
<many-to-one name="department" class="com.java.commons.Department" column="department"  />

Details for Many-To-One

