Quote:
<class name="com.iwms.hibernate.JavaBeans.TestFK.DependentDetails" table="dependents">
<id name="depId" type="java.lang.String" column="depid" ></id>
<property name="empId" type="java.lang.String" column="empid" length="30" />
<property name="name" type="java.lang.String" column="name" length="30" />
</class>
Here you have mapped the empId as String. But it actually points to an Employee object. So in OO paradigm, the property should be of type EmployeeDetails. So the mapping should be like:
Code:
<class name="com.iwms.hibernate.JavaBeans.TestFK.DependentDetails" table="dependents">
<id name="depId" type="java.lang.String" column="depid" >
<generator class="native"/>
</id>
<many-to-one name="employee" class="com.iwms.hibernate.JavaBeans.TestFK.EmployeeDetails" cascade="none" column="empid" />
<property name="name" type="java.lang.String" column="name" length="30" />
</class>
public class DependentDetails implements Serializable{
private static final long serialVersionUID = 1L;
private EmployeeDetails employee;
private String depId;
private String name;
.............
.............
public EmployeeDetails getEmployee() {
return employee;
}
public void setEmployee(EmployeeDetails employee) {
this.employee= employee;
}
.............
.............
}