Hi
I'm using Hibernate 3.2.5 and I would like to map a nested many-to-one relationship.
Let me explain with details:
I have 3 tables: EMPLOYEE, SECTOR, AREA
Every EMPLOYEE belongs to a SECTOR, every SECTOR belongs to an AREA, which means I have the SECTOR_ID column on EMPLOYEE table and I have AREA_ID column on SECTOR table.
So on Employee.hbm.xml I have:
Code:
<many-to-one name="Sector" class="org.hibernate.persistentObj.Sector" fetch="select">
<column name="SECTOR_ID" precision="22" scale="0" not-null="true" />
</many-to-one>
while in Sector.hbm.xml I have:
Code:
<many-to-one name="Area" class="org.hibernate.persistentObj.Area" fetch="select">
<column name="AREA_ID" precision="22" scale="0" not-null="true" />
</many-to-one>
This way, I can access Area from Employee object using:
Code:
Employee.getSector().getArea()
My goal is to map the Area object on the Employee.hbm.xml itself.
I know I could add a getArea() method on Emplyee which returns the getSector.getArea(), but I want to access the Area at hbm.xml level
Is it possible?
Thanks in advance