-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Nested many-to-one mapping
PostPosted: Thu Mar 27, 2008 6:33 am 
Newbie

Joined: Fri Mar 14, 2008 6:59 am
Posts: 6
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.