views:

24

answers:

0

I have the following mapping:

<class where="IsDeleted = 0 or IsDeleted is null" name="File" table="tblFiles">
  <id name="Id">
    <column name="oid" />
    <generator class="sequence">
      <param name="sequence">tblFiles_SEQ_OID</param>
    </generator>
  </id>
  <property name="IsDeleted" type="System.Boolean">
    <column name="IsDeleted" />
  </property>
  <joined-subclass name="NestedFile" table="tblNestedFiles">
    <key>
      <column name="FileId" />
    </key>
    ...
  </joined-subclass>
</class>

When NHibernate performs a query to get a NestedFile, it is applying the where clause to the NestedFiles table and not the files table:

SELECT files0_.OtherId         as MrdId1_,
   files0_.FileId        as FileId1_,
   files0_.FileId        as oid10_0_,
   files0_1_.IsDeleted   as IsDeleted10_0_,
   files0_.OtherId         as MrdId11_0_
FROM   .tblNestedFiles files0_
   inner join tblFiles files0_1_
     on files0_.FileId = files0_1_.oid
WHERE  (files0_.IsDeleted = 0
     or files0_.IsDeleted is null)
   and files0_.OtherId = 162 /* :p0 */

Any idea how to fix this?