I have 2 Tables
Table 1: Employee
column1:INDEX_NO
...
.....
columnN:description (foreign Key to Designation INDEX_NO)
Employee.hbm.xml:
<hibernate-mapping package="com.salary.model">
<class name="Employee" table="EMPLOYEE">
<id name="index_no" column="INDEX_NO">
<generator class="identity" />
</id>
<property name="emp_id" not-null="true" unique="true" column="EMP_ID" />
<many-to-one name="designationDescription" fetch="join" class="com.salary.model.Designation">
<column name="DESIGNATION" not-null="true" />
</many-to-one>
</class>
Employee.java
public class Employee {
private Long index_no;
public Integer designation;
private Designation designationDescription=new Designation();
//getter and setter
}
Table 2: Designation
column1: INDEX_NO
...
columnN: Description
Designation.hbm.xml
<class name="Designation" table="DESIGNATION">
<id name="indexNo" column="INDEX_NO">
<generator class="identity" />
</id>
<property name="coreValue" column="CORE_VALUE" />
<property name="description" column="DESCRIPTION" />
<!-- <set name="employees" table="Employee"
inverse="true" lazy="true" fetch="join">
<key>
<column name="INDEX_NO" not-null="true"/>
</key>
<one-to-many class="com.salary.model.Employee"/>
</set>
-->
</class>
Everything is fine till now:
But when i try to fetch it in my
java class with following statement:
empList = session.createQuery("select e from Employee as e ").list();
i am gettting
designationDescription having null values and some unwanted handler object ..see attachment for debugging mode snapshot .
This object is of Type Designation and it should contain INDEX_NO,Description in it but they are null as of now and some unwanted object is visible in debugging mode.