Hello

I have following class:
  public class BaseBox
  {
    public virtual int Id
    {
      get;
      protected set;
    }

    public virtual BaseBox ParentBox
    {
      get;
      set;
    }


    public virtual IList<BaseBox> Children
    {
      get;
      protected set;
    }
  }

With following mapping:
<hibernate-mapping>
  <class name="BaseBox" table="BOX_HST" where="FirstEffDt &lt; GETDATE() AND
(LastEffDt IS NULL OR LastEffDt &gt;= GETDATE())" >
    <id column="BoxId" name="Id">
      <generator class="native"/>
    </id>

    <many-to-one name="ParentBox" class="BaseBox">
      <column name="ParentBoxId" />
    </many-to-one>

    <set name="Children" lazy="true">
      <key>
        <column name="BoxId" />
      </key>
      <one-to-many class="BaseBox" />
    </set>

  </class>
</hibernate-mapping>

Key thing here is that "class" tag has "where" attribute defined.

When I access "ParentBox" property of just fetched (using getbyid) object
then NHibernate generates SELECT statement with condition that I've
specified in "where" attribute of "class" tag.

But when I access "Children" property this additional condition is missing.

I can add the same "where" condition to "set" tag but I think it is wrong
way since I'll have to copy-paste the same expression for dozens of same
collections.

I've also tried to use filters but got the same issues.

Maybe I'm missing something? But I expect that filters and "where"
attributes would work the same way if I use "filtering view" in database.

--

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