Hi Alex, I created a pull request about the tests and commented to the issue about a proposal for a fix.
-Tatu On Saturday, October 13, 2012 3:56:56 PM UTC+3, Alexander I. Zaytsev wrote: > > Hi, > > It seems that it is a well-known issue > https://nhibernate.jira.com/browse/NH-2354 and this was closed as "not an > issue". But I think in case of union-subclass it is possible to > implement... > > I've reopened the issue in JIRA, so if you want you can attach a test case > with or without the fix. > > Best Regards, Alex. > > 2012/10/13 proge <[email protected] <javascript:>> > >> I'm by no means an NHibernate expert so please let me know if I'm just >> approaching this case wrong in my mapping. >> >> I was digging into some unexpected behavior that I ran into when using >> union subclasses and trying to map an abstract Name-property of a >> Party-entity, which is inherited by Company and Person-entities, which >> define the actual value for the name (simply company's name for a Company, >> firstname + " " + lastname for a Person). Please see >> http://stackoverflow.com/questions/12762682/how-to-map-an-abstract-property-with-nhibernate-union-subclass >> for >> a more detailed description of both the model and the mapping used. >> >> Today I finally had time to try and debug the NHibernate-core-3.3.1 GA >> sources to try to find what I'm doing wrong. I noticed that in >> AbstractPropertyMapping's AddPropertyPath -method, the code is not checking >> whether columns for some property path already exist, but simply assigns >> the value for a given path (thus overwriting if the path already had some >> columns defined). This results in the where clause being something like >> -- WHERE this_.company_name like 'queryParameterValue' -- when I'd expect >> it to be something like -- WHERE this_.company_name like >> 'queryParameterValue' OR first_name || ' ' || last_name like >> 'queryParameterValue'. >> >> protected void AddPropertyPath(string path, IType type, string[] columns, >> string[] formulaTemplates) >> { >> typesByPropertyPath[path] = type; >> columnsByPropertyPath[path] = columns; // These values for keys should >> probably not be just set, but also checked for previous values >> >> if (formulaTemplates != null) >> formulaTemplatesByPropertyPath[path] = formulaTemplates; >> } >> >> The formulaTemplatesByPropertyPath variable is also related here, as I'm >> using a formula (afaik the formulas are not checked at all >> when GetColumnNames (AbstractPropertyMapping:217) is called when building >> the query). However, the problem seems to exist also when no formulas are >> involved, as I tried to change the mapping so that Person's "Name" property >> refers to the first_name as per the mapping below: >> >> <union-subclass name="Person" table="`person`" extends="Party"> >> <property name="Name" access="field.camelcase-underscore" >> update="false" insert="false"> >> <column name="first_name"/> >> </property> >> <property name="FirstName"> >> <column name="first_name" /> >> </property> >> <property name="LastName"> >> <column name="last_name" /> >> </property> >> </union-subclass> >> >> So what I'm wondering is that is this actually a bug, or am I just simply >> missing something? This behavior seems unexpected to me and this first look >> at a code makes me to think that the behavior is not intended. Also, please >> let me know if this is not the right place to report a bug. >> >> - proge >> >> -- >> You received this message because you are subscribed to the Google Groups >> "nhusers" group. >> To view this discussion on the web visit >> https://groups.google.com/d/msg/nhusers/-/zrwjlg7IRkQJ. >> To post to this group, send email to [email protected]<javascript:> >> . >> To unsubscribe from this group, send email to >> [email protected] <javascript:>. >> 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 view this discussion on the web visit https://groups.google.com/d/msg/nhusers/-/AcQAzJMy7pwJ. 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.
