I have a class which maps to two tables. I utilized the reference to configure but the configuration does not match with my class. Would you help me the correct configuration, please?
EmployeeDetail.java
Code:
public class EmployeeDetail implements Serializable {
private static final long serialVersionUID = 1L;
private String staffId;
private String displayName;
private String deptId;
private String deptName;
... getter and setter...
EmployeeDetail.hbm.xml
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.stanley1610.bus.EmployeeDetail" table="Employee"
entity-name="EmployeeDetail_Employee" lazy="false">
<id name="staffId" column="staffId">
<generator class="native"/>
</id>
<property name="displayName">
<column name="displayName"/>
</property>
<many-to-one name="deptId"
entity-name="EmployeeDetail_Department"
column="deptId"
not-null="false" />
</class>
<class name="com.stanley1610.bus.EmployeeDetail" table="Department"
entity-name="EmployeeDetail_Department" lazy="false">
<id name="deptId" column="deptId">
<generator class="native"/>
</id>
<property name="deptName">
<column name="name"/>
</property>
</class>
</hibernate-mapping>
Tables:
Employee {staffId*, displayName, deptId}
Department {deptId*, name}
Error:
2009-07-11 22:56:17,021 ERROR [org.hibernate.property.BasicPropertyAccessor] - IllegalArgumentException in class: com.stanley1610.bus.EmployeeDetail, setter method of property: deptId
2009-07-11 22:56:17,021 ERROR [org.hibernate.property.BasicPropertyAccessor] - expected type: java.lang.String, actual value: com.stanley1610.bus.EmployeeDetail
Please help~