We have a class, *SpecialContainer *(itself a subclass of *Container*), 
that has a list of contents of type *TypeThreeContent*:

class SpecialContainer {
  private IList<TypeThreeContent> _contents = new List< 
TypeThreeContent >();
}


TypeThreeContent is just a subclass of BaseContent, both of which have some 
uninteresting properties I've omitted for simplicitly.  Here's the mapping:

<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
  <class xmlns="urn:nhibernate-mapping-2.2" discriminator-value="0" 
name="AbstractBaseContent" table="tblContent">
    <id access="field" name="_id" type="System.Int32" unsaved-value="0">
      <column name="ContentID" />
      <generator class="identity" />
    </id>
    <discriminator type="Int32">
      <column name="FormsType" />
    </discriminator>
    <subclass name="TypeOneContent" discriminator-value="1">
    </subclass>
    <subclass name="TypeTwoContent" discriminator-value="2">
    </subclass>
    <subclass name="TypeThreeContent" discriminator-value="3">
    </subclass>
  </class>

  <class xmlns="urn:nhibernate-mapping-2.2" discriminator-value="-1" 
name="BaseContainer" table="tblContainers">
  ...
  <subclass name="SpecialContainer" discriminator-value="1">
      <join table="tblSpecialContainers">
      ...
        <bag access="field" cascade="none" inverse="true" lazy="true" 
name="_contents">
          <key>
            <column name="ContainerId" />
          </key>
          <one-to-many class="TypeThreeContent" />
        </bag>
</join>
  </class>
</hibernate-mapping>


The problem I'm having is that rows with other discriminator values (i.e. 1 
and 2) are getting picked up in NH's fetching of the list.  I used NHProf 
to verify that the SQL query is *not* specifying a discriminator in its 
criteria:

SELECT ...
FROM   dbo.tblContent content0_
WHERE  content0_.SpecialContainerId = 140 /* @p0 */


What's going on here?

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/nhusers/-/ymmMPlkIXdQJ.
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