I ended up just putting a special post-load check on my get/load repository
methods to check if the object fails the filter. Not perfect, but in my case
did not add too much overhead. Another option is the load objects via
criteria instead of via Get/Load.
On Tue, Oct 28, 2008 at 2:29 PM, CassioT <[EMAIL PROTECTED]> wrote:
>
> But why log shows the query with the filter? This is what happens to
> me.
>
> I wasn't understanding what was happening until I've read this post.
>
> And unfortunately I wish to filter even when using Get or Load.
>
> Any sugestions?
>
> On 14 set, 11:06, "Fabio Maulo" <[EMAIL PROTECTED]> wrote:
> > By design.Filters don't work with Get or Load since they mean: I want
> load
> > the entity with this ID.
> > Dynamic filters work with HQL/Criteria and Collection(where enabled for a
> > collection) only when you use explicit joins or, more general, when the
> > QuerySpace of a filter match with the QuerySpace of a query.
> >
> > 2008/9/10 Will Shaver <[EMAIL PROTECTED]>
> >
> >
> >
> > > Noticing some inconsistancies with object loading, and was wondering if
> any
> > > of you knew if this was expected behavior or a bug.
> >
> > > I've included a patch for DynamicFilterTest.cs in the FilterTest folder
> of
> > > the nhibernate tests, but basically it's like this:
> >
> > > Filters don't seem to work on the primary entity if loaded via
> > > ISession.Load or ISession.Get. They'll still work on joined entities
> (marked
> > > as lazy=false in the hbm). Filters do work via HQL or Criteria
> >
> > > So if I do
> >
> > > session.EnableFilter("Region").SetParameter("Region","THISONEISBAD");
> >
> > > //this returns the Salesperson, but it should not
> > > session.Get(typeof(Salesperson),id)
> >
> > > //this returns null as expected.
> > > session.CreateQuery("from Salesperson as s where s.id =
> > > :id").SetParameter("id",id).UniqueResult();
> >
> > > //this returns null as expected
> >
> > >
> session.CreateCriteria(typeof(Salesperson)).Add(Restrictions.IdEq(id)).UniqueResult();
> >
> > > So what gives? Is this by design? Should I work to fix this, or is this
> > > intended?
> >
> > --
> > Fabio Maulo
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---