gauravrajbehl wrote:
Hi,
I have 2 classes (1) Designation (2) Responsibility. A designation can have multiple responsibilities, so I created a Set for the same in the Designation Class to get all the responsibilities for a Designation. Below are the details:
Class Designation {
private Integer id;
private String name;
private Set<Responsibility> responsibilities;
Getters & Setters.....
}
Table Structure for Designation: id, name
Class Responsibility {
private Integer id;
private String name;
private Integer designation_id;
Getters & Setters.....
}
Table structure for Responsibility: id, name, designation_id
Hibernate Mapping:
<set name="responsibilities">
u can have a set of responsibilities related to this Designation.
<key column="designation_id" />
This refers to the foreign key property of the responsibilities field.There will be a designation_id property in the responsibilities class/table mapping to the primary key of designation.
<one-to-many class="Responsibility" />
From a desigantion to many responsibilities!
</set>
Now, I am not sure whether the above mapping is correct or not. If its correct, what does it mean in simple words, what does <key> column mean with respect to the above mapping.
Thanks
Regards