Hi,
Please forgive of the question is stupid...I am a beginner...
How should I map to suit this situation?
I have two entities Employee and Location. The Location table in the database
has to be just used as a static lookup table to populate a drop down box in my JSP.
The problem is that when I fetch the details from the database, the employee object should come with the location object as a child, but when i try to save an employee object, the employee table should just get updated with the foreign key alone, a new location object should not be inserted.
Here is the table structure
Code:
Table EMPLOYEE
Employee_Id
Employee_Name
Employee_Role
Location_CD - FK (Location.Location_CD)
Table Location
Location_CD
Location_Name
Here are the mapping files:
Code:
EMPLOYEE
<class name="Employee" table="EMPLOYEE">
<id name="employeeID" column="Employee_Id">
</id>
<property name="empName" column="Employee_Name"/>
<property name="empRole" column="Employee_Role"/>
<many-to-one name="empLocation"
column="Location_CD"
unique="true"
fetch="join"/>
</class>
LOCATION
<class name="Location" table="Location">
<id name="locationCD" column="Location_CD">
</id>
<property name="locationName" column="Location_Name"/>
</class>
How should i modify the mapping file of Employee so that the child location is not saved during save of employee? But i do need the location object during the select operation.
Any help is greatly appreciated!!