It looks like a bug... the filter should probably be on the join clause. You can open an issue at http://jira.nhforge.org/. Make sure to include a failing test.
As a hacky workaround, you could change your filter to something like "(Id is null or Deleted = :isdeleted)". Disclaimer: I have no idea if that will work, but it won't hurt to try. Diego On Mon, Apr 5, 2010 at 11:01, Sean Chambers <[email protected]> wrote: > Should I perhaps rephrase this question? Does anyone understand what > it is i'm runnin into? > > Thanks > > Sean > > On Apr 1, 4:03 pm, Sean Chambers <[email protected]> wrote: > > Any ideas? I'm sure this is a simple use case of filters. I feel like > > im doing something silly and this should be an easy fix. or perhaps > > not > > > > On Apr 1, 8:54 am, Sean Chambers <[email protected]> wrote: > > > > > > > > > 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]<nhusers%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/nhusers?hl=en. > > -- 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.
