mix ? On Sat, Mar 26, 2011 at 4:03 PM, Anne Epstein <[email protected]> wrote:
> Fabio, > There is some chance this is fixed in NHibernate 3.X as I haven't > needed to use the <join> feature in a while, but Krzysztof's issue > sounded like a sister issue to one I ran across, researched and > reported, and that bug report is still unresolved: > http://216.121.112.228/browse/NH-1747 > > 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 > > > > On Sat, Mar 26, 2011 at 1:07 PM, Fabio Maulo <[email protected]> wrote: > > Anne, > > can you point me to the list of actual open issues, about the problems > you > > are talking about, in our JIRA ? > > where no available in the ticket, can you provide a failing test ? > > Thanks. > > > > On Fri, Mar 25, 2011 at 4:28 PM, 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/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 [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 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. > >> > > > > > > > > -- > > 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. > > > > -- > 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.
