I have a soft delete filter I am applying to all entities like so:

<entity xml>
   <filter name="NotDeletedFilter" />
</entity xml>

My filter def looks like this:

<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default-
access="property" auto-import="true" default-cascade="none" default-
lazy="true">
  <filter-def name="NotDeletedFilter" condition="Deleted
= :isdeleted" />
</hibernate-mapping>


The filter applies fine, the only problem is with associated entities
of the one I am retrieving. Having this filter applied to all entites
causes for where clauses to be added to all associations, which in
certain cases where the association is null, causes the main record to
never be returned.

Ie. I have a user that has a many-to-one association with Company.
Upon selecting a user the following query gets built:

FROM   Users this_
       left outer join Companies company4_
         on user3_.CompanyId = company4_.Id
WHERE
       and company4_.Deleted = 0
       AND 1 = 1

In this instance the query is retrieving all users most of which,
_user3_.CompanyId is NULL as it is not a required association.

Other clauses were ommitted for brevity, but this shows that with this
filter applied, the where clause prevents from any records for the
main entity from being returned because of the where clause.

Has anyone run into applying a site wide filter and running into
problems like this?

-- 
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