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
|