I am looking at the mapping given on pg. 143 of Hibernate 3.0 reference manual.
In a more complex example, imagine that the association between Employee and Organization
is maintained in an Employment table full of historical employment data. An association to the
employee's most recent employer, the one with the most recent startDate, could be mapped in
the following way:
I don't think I understand this mapping at all. The following is what my understanding is:
1. Employee class has a field named mostRecentEmployer of class Oganization.
2. There is an Employment table containing EmployeeId, OrgId, StartDate, and EndDate columns.
3. Now, where does the above <join> construct appear? In the mapping for Employee.hbm.xml or Organization.hbm? I guess, it is in Employee.hbm, right?
4. What does <key column="employeeId"/> mean? It is a key for what?
5. In the <subselect>, I don't understand "having startDate = max(startDate)". Is this HQL?
Please help me understand this. How to "read" this mapping?