|
From: Andrei A. (JIRA) <nh...@gm...> - 2011-05-16 14:50:48
|
[ http://216.121.112.228/browse/NH-2705?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=21092#action_21092 ]
Andrei Alecu commented on NH-2705:
----------------------------------
Alright, then I guess the bug is that there's not a clear exception being thrown if this is not a supported scenario. :)
I believe we should get an exception instead of executing invalid SQL.
Regarding not being able to fetch through components, I believe that's also a bug, your comment:
The LINQ
session.Query<T>().Fetch(p => p.SubItem.Details).Where(p => p.SubItem.Name == name).ToList();
is NH-2615
Results in the following error:
A fetch request must be a simple member access expression of the kind o => o.Related; 'p.SubItem.Details' is too complex.\r\nParameter name: relatedObjectSelector
So, there's no way to fetch through components currently.
> 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
> Priority: Minor
> 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
|