-->
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.  [ 4 posts ] 
Author Message
 Post subject: mapping question
PostPosted: Tue Nov 06, 2007 9:28 pm 
Newbie

Joined: Tue Oct 24, 2006 8:41 pm
Posts: 3
Hi. Im trying to map Areas and Persons.
Each Area has 4 specific persons.
1. A Warden
2. A Chief Warden
3. A Comms Officer
4. A Deputy Chief Warden

I have modelled this as an Area object containing a 'warden' Person object, a 'chiefWarden' Person object, a 'deputyChiefWarden' person object etc.

The Person object has firstName, lastName etc.

I will be accessing the Person object as area.getChiefWarden().getFirstName() etc.

I currently dont have an area property in the person object (or areaid in the person db table)

How do I map this in the hbm.xml file?
Ive looked at one-to-one mapping (many to one with unique="true") but this doesnt seem to be whats needed.
Can I just set the Person objects as properties in the Area object and then specify the type?

Thanks for help.
Kr.
Luke.


Top
 Profile  
 
 Post subject: Re: mapping question
PostPosted: Tue Nov 06, 2007 10:32 pm 
Newbie

Joined: Tue Oct 24, 2006 8:41 pm
Posts: 3
Heres my hbm.xml snippet in addition:

edencane wrote:
Hi. Im trying to map Areas and Persons.
Each Area has 4 specific persons.
1. A Warden
2. A Chief Warden
3. A Comms Officer
4. A Deputy Chief Warden

I have modelled this as an Area object containing a 'warden' Person object, a 'chiefWarden' Person object, a 'deputyChiefWarden' person object etc.

The Person object has firstName, lastName etc.

I will be accessing the Person object as area.getChiefWarden().getFirstName() etc.

I currently dont have an area property in the person object (or areaid in the person db table)

How do I map this in the hbm.xml file?
Ive looked at one-to-one mapping (many to one with unique="true") but this doesnt seem to be whats needed.
Can I just set the Person objects as properties in the Area object and then specify the type?

/~~~~~~~~~~~~~~~~~~~~~~~~~
This is how Ive currently got it
<class name="Area" table="emm_area">
<id name="id" column="areaid">
<generator class="native"/>
</id>
<property name="name"/>
<many-to-one name="premise"
class="Premise"
column="premiseid"
not-null="true"/>
<many-to-one name="chiefWarden"
class="Person"
column="chiefwarden"
unique="true"
not-null="false"/>
</class>

<class name="Person" table="emm_person">
<id name="id" column="personid">
<generator class="native"/>
</id>
<property name="firstName"/>
<property name="lastName"/>
<property name="username"/>
<property name="password"/>
<property name="mobile"/>
</class>
\_____________________________________




Thanks for help.
Kr.
Luke.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 07, 2007 12:44 pm 
Beginner
Beginner

Joined: Tue Jun 26, 2007 2:31 pm
Posts: 21
Does the emm_area table hold a foreign key for person to have a many-to-one relation


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 07, 2007 5:51 pm 
Newbie

Joined: Tue Oct 24, 2006 8:41 pm
Posts: 3
sainaveenp wrote:
Does the emm_area table hold a foreign key for person to have a many-to-one relation


Thanks for your response.

The emm_area table has 4 fields that uniquely identify a person...
chiefwarden
deputychiefwarden
warden
commsofficer

so person could have a many-to-one on chiefwarden, a many-to-one on deputychiefwarden etc...

Kr.
Luke.


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

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.