I have a fairly complex domain model in which classes A and F are
indirectly related.  The query to get the data I want would require 6
joins and would be very inefficient.  However A and F both have
property 1 and property 2 which would be sufficient for the join.
Neither Property 1 nor Property 2 are primary keys in either class.  I
would for class A to have a collection of F where F.Property1 =
A.Property1 and F.Property2 = A.Property2.  The inverse is not
necessary.  This "shortcut collection" would make the query easy and
much more efficient.  However I haven't found a way to map this
collection.  Here's what I've tried:

<class name="A" table="A_TBL">
<id name="Id" column="ID_NBR" type="long">
      <generator class="identity" />
</id>
<property column="AProp1Column" name="Property1" />
<property column="AProp2Column" name="Property1" />
<bag name="Fs" table="F_TBL" inverse="true" cascade="none">
      <key>
        <column name="AProp1Column" property-ref="Property1"/>
        <column name="AProp2Column" property-ref="Property2"/>
      </key>
      <one-to-many class="F" />
</bag>
</class>

<class name="B" table="B_TBL">
<id name="Id" column="ID_NBR" type="long">
      <generator class="identity" />
</id>
<property column="BProp1Column" name="Property1" />
<property column="BProp2Column" name="Property1" />
</class>

Unfortunately the column element does not have a property-ref
attribute.  Is there another way I can acomplish this?  I'm leaning
towards raw SQL and skip the mapping, but I have a feeling there is a
way to do it in NHibernate.

Thanks,
Robert Graves
--~--~---------~--~----~------------~-------~--~----~
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