Hi,

We have a table named "Son" with a composite primary key which has two
foreign keys from its "Parent" (the parent has two fields as its
primary key) .

- PK         IdSon
- PK (FK) Id1Parent
- PK (FK) Id2Parent

having the following mapping:

SON:
*************************************************
<composite-id>
      <key-property name="IdSon" column="IdSon"
access="field.camelcase-underscore" />
      <key-many-to-one name="Parent"  access="field.camelcase-
underscore"  >
        <column name="Id2Parent" />
        <column name="Id1Parent" />
      </key-many-to-one>
</composite-id>
*************************************************

PARENT:
<composite-id>
      <key-property name="Id1Parent" column="Id1Parent"
access="field.camelcase-underscore" />
      <key-many-to-one name="Id2Parent" column="Id2Parent"
access="field.camelcase-underscore" />
</composite-id>
*************************************************

I have been trying to make work the following LINQ:

var Sons = from son in CurrentSession.Query<Son>()
                 where
                 son.IdSon == pIdSon &&
                 son.Parent.Id1Parent == pId1Parent &&
                 son.Parent.Id2Parent == pId2Parent

I Could see that the order really matters on the mapping, If you take
a look again on Son, the parent's foreign composite key Ids are
inverted (first: Id2Parent, second: Id1Parent) and they differ from
the order on the Parent's side.

As a result. NHibernate interprets this like this:

select *
from Son s, Parent p
where
s.Id1Parent = p.Id2Parent

First question: Is this the normal behavior on  NH?
Second : Is there any chance make the order to don't matter?

I'm using Llbl Gen Pro, so the mapping is automatic, and even though I
can manage a little bit of the generation, is kind of harder to map it
in the order NH needs.

thanks a lot for your help

best regards

Rodrigo

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to