The problem with the above SQL actually is that you

1- Cannot add 'where' clause to the <join /> mapping tag
2- Cannot alternatively refer to the <join /> part in the 'where' of the
<class /> itself. There is no alias or something that you can use inside
that 'where' to refeer to the <join /> part.

I think this is the case even independent from filters completely.
Regardless of them, you still cannot have a 'where' based on columns in the
<join /> part (or can you?).



*Mohamed Meligy
*Readify | Senior Developer

M:+61 451 835006 | W: readify.net
[image: Description: Description: Description: Description:
rss_16]<http://gurustop.net>
[image: Description: Description: Description: Description:
cid:[email protected]]
<http://www.linkedin.com/in/meligy>  [image:
Description: Description: Description: Description:
cid:[email protected]] <http://twitter.com/meligy>
 
<http://www.greatplacetowork.com.au/best/best-companies-australia.php><http://www.readify.net/AboutUs/NewsItem.aspx?id=10>



On Sat, Mar 26, 2011 at 9:52 AM, xtoff <[email protected]> wrote:

> @Anne - I'm open to ideas how to solve the underlying problem (having
> multilingual app that in C# model is single-language) differently.
> That's more important to me short term than having the eforementioned
> bug fixed.
>
> @Fabio - WRT the warning, I'm not sure what Ayende meant. I tried his
> solution and it works on 3.1. That's actually my fallback solution for
> now.
>
> On Mar 26, 5:28 am, Anne Epstein <[email protected]> wrote:
> > The <join> mapping is problematic in that various features in
> > NHibernate will assume that fields, keys, etc are in the primary table
> > that may actually be in the secondary table-resulting in errors.
> > There are a number of bugs in jira related to this kind of problem
> > with the <join> element.  At this point, until there is a real
> > solution that consistently makes NHibernate deal with this
> > relationship properly in all NHibernate features (and I wouldn't hold
> > my breath), I'd avoid this mapping strategy unless you absolutely have
> > to- you'll almost certainly hit some weirdness if you try anything
> > complex/interesting.
> >
> > On Fri, Mar 25, 2011 at 1:25 PM, José F. Romaniello
> >
> >
> >
> >
> >
> >
> >
> > <[email protected]> wrote:
> > > It is not the same, he is using a filter inside the "where" attribute
> > > of the <class> to filter by a column in a <join>. It is different to
> > > the formula of Ayende.... But im not sure if it might work
> >
> > > 2011/3/25, Fabio Maulo <[email protected]>:
> > >> If you use that solution, please have a look to WARNING.
> >
> > >> 2011/3/25 Krzysztof Koźmic <[email protected]>
> >
> > >>> So I have a one-to-many tables in database that looks like the
> following
> > >>> (I'm on NHibernate 3.1):
> >
> > >>> blog
> > >>>    id
> > >>>    title
> > >>>    author
> >
> > >>> comments
> > >>>    id
> > >>>    blog_Id
> > >>>    languageid
> > >>>    comment
> >
> > >>> and I want to map it to a *single* class with *single* comment
> property
> > >>> that maps to text column in comments table for current language.
> >
> > >>> Basically the idea is identical to one ayende had few years back:
> > >>>
> http://ayende.com/Blog/archive/2006/12/26/localizingnhibernatecontext...
> >
> > >>> The difference is I try to accomplish this without subselect but
> using
> > >>> <join /> instead (mostly because the table with translations has more
> > >>> columns than just the text that I may need to include in my joined
> class).
> >
> > >>> So I created a solution for that and I'm also using filter to pass
> > >>> language
> > >>> id to queries. I also have a noop property in my mapping for the
> > >>> languageid
> > >>> as well as where clause in my mapping that does the filtering.
> >
> > >>> And here's the SQL that NHibernate generates:
> >
> > >>> SELECT this_.Id           as Id0_0_,
> > >>>       this_.Author       as Author0_0_,
> > >>>       this_.Title        as Title0_0_,
> > >>>       this_1_.Comment    as Comment1_0_,
> > >>>       this_1_.LanguageId as LanguageId1_0_
> > >>> FROM   Blog this_
> > >>>       inner join Comment this_1_
> > >>>         on this_.Id = this_1_.Blog_id
> > >>> WHERE  (this_.LanguageId = 2 /* @p0 */)
> >
> > >>> The SQL is invalid as the where should be on this_1_.LanguageId as
> the
> > >>> value comes from the joined table, not the main one.
> >
> > >>> Also the LanguageId column is mapped as access="noop" which TTBOMK
> should
> > >>> mean it won't be queried for so I'm surprised to see NHibernate is
> trying
> > >>> to
> > >>> select it as well. To me it is just wasting bandwith.
> >
> > >>> So I have two questions now.
> >
> > >>> 1. How can I accomplish what I'm trying to get to.
> > >>> 2. Are those issues I mentioned (invalid where clause and ignoring
> noop
> > >>> access) bugs in NHibernate or am I looking at it from the wrong
> angle?
> >
> > >>> Reproduction demo app (along with database dump) available here if
> someone
> > >>> wants to play with it:http://ge.tt/5xoiqYY
> >
> > >>> cheers,
> > >>> Krzysztof
> >
> > >>> --
> > >>> 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.
> >
> > >> --
> > >> 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.
> >
> > > --
> > > Enviado desde mi dispositivo móvil
> >
> > > --
> > > 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 athttp://
> 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.
>
>

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