From: Andrei A. (JIRA) <nh...@gm...> - 2011-05-18 09:23:57
|
[ http://216.121.112.228/browse/NH-2705?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=21116#action_21116 ] Andrei Alecu commented on NH-2705: ---------------------------------- I reviewed the fix, but it seems to be only for NH-2615. This particular issue (NH-2705) isn't fixed. You seem to have removed the relevant tests that were pertaining to it, so that unit test folder should instead be NH2615. :) So, even if this isn't supported (although everything else seems to work except for when Fetch is used), I think this one shouldn't be marked fixed, because that query still generates invalid sql. Maybe "won't fix"/"by design", or maybe let it stay open if someone wants to still fix it some time in the future. However, in my case, I was mainly interested in NH-2615, so - thanks Fabio! :) > Linq/Hql/Criteria Fetch on class hierarchy generates invalid SQL when derivees mix component and many-to-one mappings > --------------------------------------------------------------------------------------------------------------------- > > Key: NH-2705 > URL: http://216.121.112.228/browse/NH-2705 > Project: NHibernate > Issue Type: Improvement > Components: Core > Affects Versions: 3.1.0 > Reporter: Andrei Alecu > Assignee: Fabio Maulo > Priority: Minor > Fix For: 3.2.0Beta1 > > Attachments: nh2705 test.patch > > > Consider the following scenario: > public class ItemBase > { > public virtual int Id { get; set; } > public virtual SubItemBase SubItem { get; set; } > } > public class ItemWithComponentSubItem:ItemBase { } > > public class ItemWithManyToOneSubItem:ItemBase { } > ItemWithComponentSubItem defines in its mapping that SubItem is a component of SubItemComponent type (which derives from SubItemBase) > ItemWithManyToOneSubItem defines in its mapping that SubItem is a many-to-one of SubItemEntity type (again, derives from SubItemBase) > Running the following query with fetch results in invalid SQL being executed: > from ItemBase i left join fetch i.SubItem > Removing the fetch makes it work properly. > from ItemBase i > Also, this works: > from ItemWithManyToOneSubItem i left join fetch i.SubItem > But this doesn't: > from ItemWithComponentSubItem i left join fetch i.SubItem (one would argue there's nothing to fetch here, but instead of throwing an exception, the fetch instruction should just be ignored and maybe a warning logged, it would allow for much better reuse of code) > I will attach a unit test that demonstrates this bug, and also a related one at NH-2615. > I believe the correct behavior here is to allow fetch on components, and simply ignore it rather than throwing an exception. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://216.121.112.228/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |