-->
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.  [ 2 posts ] 
Author Message
 Post subject: mapping 3 tables
PostPosted: Thu Feb 16, 2006 6:06 pm 
Beginner
Beginner

Joined: Wed Feb 15, 2006 2:51 pm
Posts: 20
Hello,

I am trying to map 3 tables.

people
positions
position status.

position has a foreign key to both people and positions status.

The mappings are fine when i select just from 2 tables.

But when i try to select status for a position for a cretin person i get all the positions with where position status= to the pos for the record that I want to select

I have


<!-- bi-directional many-to-one association to People -->
<many-to-one
name="person"
class="org.ultimania.model.Person"
not-null="true"
>
<column name="PPL_ID" />
</many-to-one>

<!-- bi-directional one-to-one association to MasterSubtypeList -->
<many-to-one
name="masterSubtypeListByPositRoleSubtypesId"
class="org.ultimania.model.MasterSubtypeList"
unique="true"
>
<column name="POSIT_ROLE_SUBTYPES_ID" />
</many-to-one>



I try to do the following.

List peepsList = session.createQuery("from Person where ppl_id = 10496").list();
//
for (Iterator iter = peepsList.iterator(); iter.hasNext();)
{
Person peeps = (Person) iter.next();
System.out.println("First name " + peeps.getLname() + "Last name " + peeps.getLname());

for (Iterator iter2 = peeps.getPositions().iterator(); iter2.hasNext();)
{
Position pos = (Position)iter2.next();
System.out.println("Pos Name " + pos.getName());
System.out.println("Pos Subtype " + pos.getMasterSubtypeListByPositRoleSubtypesId().getDescr());
}
}

When i try to get the positions subtype, i get all positions that have that subtype, instead getting a positions with only one subtype.

How do i relate the 3rd table to the first one with out using any code?? Do i have to map it differently?


thank you


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 17, 2006 12:25 pm 
Beginner
Beginner

Joined: Wed Feb 15, 2006 2:51 pm
Posts: 20
bump!! help


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.