Why do I *need* an explicit join? If a filter can be applied to a one-
to-many collection, why cannot the same functionality be available for
a many-to-one??
I can lazily load a collection with a filter, why will NHibernate
*NOT* let me do this with a many-to-one? I have heard you say that
this does not guarantee the integrity of the model. It is the
responsibility of the user to ensure that *their* explicit
configuration ensures the integrity of the model. I have several many-
to-one fields on each of my entities that require this filter.. I
cannot join on all of them simultaneously when loading the entity.
Currently I have to resort to a hack such as this to get the desired
functionality:
public virtual MyClass ReferencedManyToOneObject {
get { ListHack.Count > 0 ? ListHack[0] : null; }
set { ListHack[0] = value; }
}
public virtual IList<MyClass> ListHack { get; set; }
And then I map ListHack as a many-to-one with the filter. THIS GETS MY
DESIRED RESULTS! But as you can see it is nothing more than a
completely dirty filthy hack and it makes me incredibly uncomfortable.
I simply wish to be able to apply a filter to many-to-one
relationships JUST as one can with one-to-many.
On Mar 18, 8:22 am, Fabio Maulo <[email protected]> wrote:
> where is the explicit join ?
>
> 2010/3/18 snicker <[email protected]>
>
>
>
> > You say that this behavior is enabled by default... If I have entity
> > Foo which references entity Bar, and each entity has the filters
> > defined in their mapping, it should "just work"? Or am I doing
> > something incorrectly?
>
> > On Mar 16, 2:59 pm, Fabio Maulo <[email protected]> wrote:
> > > because it is a many to one...
> > > To let you understand we have even added an option to disable the
> > behaviour
> > > even when the join is explicitly required.
> > > Why this options ?
> > > Because users have asked it in our JIRA and after a long discussion in
> > the
> > > development list the conclusion was the actual implementation available
> > in
> > > NH2.1.2
>
> > > 2010/3/16 snicker <[email protected]>
>
> > > > The filter is already defined in the Bar class, and it does not get
> > > > filtered. What ends up happening is it returns too many rows for the
> > > > referenced EntityId because the filter ensuring a unique result is not
> > > > applied.
>
> > > > Why does it have to be explicit? Collections can have filters and be
> > > > lazy loaded... why can't a many-to-one reference?
>
> > > > On Mar 16, 2:21 pm, Fabio Maulo <[email protected]> wrote:
> > > > > Then the many-to-one should be explicitly joined in the HQL.
>
> > > > > from Foo f join f.Bar
>
> > > > > The filter must be declared in Bar class.
>
> > > > > 2010/3/16 Fabio Maulo <[email protected]>
>
> > > > > > What you need is only put the filter in the related class, not in
> > the
> > > > > > many-to-one.
>
> > > > > > 2010/3/16 snicker <[email protected]>
>
> > > > > >> 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]>
>
> > > > <nhusers%[email protected]<nhusers%[email protected]>
> > <nhusers%[email protected]<nhusers%[email protected]>
>
> > > > > >> <nhusers%[email protected]<nhusers%[email protected]>
> > <nhusers%[email protected]<nhusers%[email protected]>
>
> > > > <nhusers%[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]>
> > <nhusers%[email protected]<nhusers%[email protected]>
>
> > > > <nhusers%[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
>
> > > > > --
> > > > > 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]>
> > <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.
>
> --
> 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.