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/localizingnhibernatecontextualparameters.aspx
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 nhu...@googlegroups.com.
To unsubscribe from this group, send email to nhusers+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.
2011/3/25, Fabio Maulo <fabio...@gmail.com>:
--
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 nhu...@googlegroups.com.
To unsubscribe from this group, send email to nhusers+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.
wow! didn't know about <subselect /> ... I learn something new about NH every day :)
Also, another related issue that I'd made note of was this:
http://216.121.112.228/browse/NH-2009
which was patched and closed, but with a patch that assumes all keys
are either in the primary table OR the join table, but doesn't really
handle a mix. The patch there is an improvement for that case, but
doesn't cover all situations.
I've seen a number of other weird issues like Krzysztof's show up on
the mailing list that were related to wrong-table FK errors on join.
Unfortunately I didn't bookmark them, but I've seen a few-enough that
I'd think twice about putting anything but plain value properties in
the secondary table of a join.
Anne
Somebody said that you need a read-only model,