When I Load an entity, that entity has many-to-one references. I need
to apply a filter to those many-to-one references. Let's say for the
sake of this discussion that I have multiple Foo entities with unique
PKs, an EntityId field with the same GUID, a DateFrom and DateTo
field, and a reference to a Bar entity. So lets say I have many Bar
entities with unique PKs, an EntityId field with the same GUID, and a
DateFrom and DateTo field.
For each of these Foo entities, they reference the EntityId that is
shared between the many Bar entities. This is essentially a many to
many relationship *until conditions have been applied*. The condition
is based on the DateFrom and DateTo fields of each entity. The ranges
are mutually exclusive, so for a Foo or Bar entity with a GUID of
"bananapancake" (Not a GUID for illustrative purposes) will never have
two entities where the Date ranges overlap. IE, when a filter is
applied, the relationship *is* a many to one. So currently, I can
apply a filter to the mapping of the entity to make this work.
<filter name="SpecificDateFilter" condition="DateFrom <= :date and
( DateTo >= :date or DateTo is NULL )" />
<filter name="CurrentDateFilter" condition="DateTo is NULL" />
So that gives me the entities that I want. However, when I go to
access a referenced Bar entity on the Foo instance, the same filter is
not applied, and I need it to be. The filter doesn't cascade. On
*collections* and have it work as I intend by applying the same
filters explicitly it within the set definition in the mapping.
I want to be able to do that exact same thing with many-to-one. There
is an entire discussion on it on the nhibernate-development mailing
list:
http://groups.google.com/group/nhibernate-development/browse_frm/thread/dca366c407b28a42/5c5f7aa4f8eeebaa?lnk=gst
and Fabio says that it's been implemented in 2.1.2. I don't know what
steps i need to take in order for this to work.
On Mar 16, 1:39 pm, Diego Mijelshon <[email protected]> wrote:
> Um... filter is not an attribute of many-to-one... (look at the schema).
> What are you trying to do exactly?
>
> Diego
>
> On Tue, Mar 16, 2010 at 16:05, snicker <[email protected]> wrote:
> > I am using 2.1.2.4000. NH throws a MappingException when I put a
> > filter element in the many to one element in my mapping. Is there
> > something specific I should be doing?
>
> > On Mar 16, 11:31 am, Fabio Maulo <[email protected]> wrote:
> > > NH2.1.2
>
> > > 2010/3/16 snicker <[email protected]>
>
> > > > I have seen some posts in the nhibernate-development mailing list
> > > > about using filters on Many To One relationships. Can anyone tell me
> > > > if this is possible, and in what version of NH? are there workarounds
> > > > if not?
>
> > > > --
> > > > 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]>
> > <nhusers%[email protected]<nhusers%[email protected]>
>
> > > > .
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/nhusers?hl=en.
>
> > > --
> > > 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]<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.