From: Andrei A. (JIRA) <nh...@gm...> - 2011-05-14 13:20:40
|
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: Bug Components: Core Affects Versions: 3.1.0 Reporter: Andrei Alecu Priority: Major 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 |
From: Andrei A. (JIRA) <nh...@gm...> - 2011-05-14 13:24:39
|
[ http://216.121.112.228/browse/NH-2705?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Andrei Alecu updated NH-2705: ----------------------------- Attachment: nh2705 test.patch Attached test that shows this bug. Also see NH-2615 which is also demonstrated by this test. > 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: Bug > Components: Core > Affects Versions: 3.1.0 > Reporter: Andrei Alecu > Priority: Major > 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 |
From: Andrei A. (JIRA) <nh...@gm...> - 2011-05-14 13:32:42
|
[ http://216.121.112.228/browse/NH-2705?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=21078#action_21078 ] Andrei Alecu commented on NH-2705: ---------------------------------- I just noticed that I forgot to include the .csproj additions in the patch, so make sure to include the NHSpecificTest\NH2705 folder in the project after applying. > 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: Bug > Components: Core > Affects Versions: 3.1.0 > Reporter: Andrei Alecu > Priority: Major > 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 |
From: Fabio M. (JIRA) <nh...@gm...> - 2011-05-16 13:11:41
|
[ http://216.121.112.228/browse/NH-2705?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Fabio Maulo updated NH-2705: ---------------------------- Priority: Minor (was: Major) > 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: Bug > 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 |
From: Fabio M. (JIRA) <nh...@gm...> - 2011-05-16 14:10:41
|
[ http://216.121.112.228/browse/NH-2705?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Fabio Maulo updated NH-2705: ---------------------------- Issue Type: Improvement (was: Bug) Changed to improv. since the Fetch (with join) on a component does not have sense. > 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 |
From: Fabio M. (JIRA) <nh...@gm...> - 2011-05-16 14:28:45
|
[ http://216.121.112.228/browse/NH-2705?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=21085#action_21085 ] Fabio Maulo commented on NH-2705: --------------------------------- The query from ItemWithComponentSubItem i left join fetch i.SubItem.Details works as expected The query from ItemBase i left join fetch i.SubItem is wrong due ItemBase does not have a property named "SubItem" The query from ItemWithComponentSubItem i left join fetch i.SubItem shows the real "matter" of this issue: Invalid join exception. The LINQ session.Query<T>().Fetch(p => p.SubItem.Details).Where(p => p.SubItem.Name == name).ToList(); is NH-2615 > 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 |
From: Andrei A. (JIRA) <nh...@gm...> - 2011-05-16 14:38:49
|
[ http://216.121.112.228/browse/NH-2705?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=21086#action_21086 ] Andrei Alecu commented on NH-2705: ---------------------------------- Huh? This is clearly a bug and not an improvement request. There is a SubItem property on ItemBase: public class ItemBase { public virtual int Id { get; set; } public virtual SubItemBase SubItem { get; set; } } Wrong SQL is being generated, I don't see how asking for valid SQL is an improvement request. > 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 |
From: Fabio M. (JIRA) <nh...@gm...> - 2011-05-16 14:39:00
|
[ http://216.121.112.228/browse/NH-2705?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=21088#action_21088 ] Fabio Maulo commented on NH-2705: --------------------------------- Test available on trunk in NHibernate.Test.NHSpecificTest.NH2705 > 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 |
From: Fabio M. (JIRA) <nh...@gm...> - 2011-05-16 14:43:45
|
[ http://216.121.112.228/browse/NH-2705?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=21089#action_21089 ] Fabio Maulo commented on NH-2705: --------------------------------- You are asking to ignore the "Invalid join" exception when the query ask for a join with a component. The ItemBase for NH does not have the property SubItem, in fact in the LINQ you are using the concrete subclass and not the base. > 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 |
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 |
From: Fabio M. (JIRA) <nh...@gm...> - 2011-05-16 14:53:48
|
[ http://216.121.112.228/browse/NH-2705?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=21093#action_21093 ] Fabio Maulo commented on NH-2705: --------------------------------- That is right. I'll comment on that issue. > 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 |
From: Fabio M. (JIRA) <nh...@gm...> - 2011-05-16 15:15:47
|
[ http://216.121.112.228/browse/NH-2705?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=21096#action_21096 ] Fabio Maulo commented on NH-2705: --------------------------------- Andrei, for this test there is no problem but, as advise, don't try to put a component with an entity in the same hierarchy; the case is not supported by neither ObjectRelationalMapping nor NHibernate and is not supposed to work always. > 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 |
From: Andrei A. (JIRA) <nh...@gm...> - 2011-05-16 15:59:46
|
[ http://216.121.112.228/browse/NH-2705?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=21097#action_21097 ] Andrei Alecu commented on NH-2705: ---------------------------------- Thanks Fabio. I understand the considerations, but I think I took the necessary precautions (only having Id in the many-to-one subclass, separate subclasses, etc), and it seems to work in our application otherwise, except for this fetch issue. I'm mostly just interested in NHibernate being able to ignore the Fetch on component, so I can have repository methods that can take either subclass and not throw an invalid join exception. Less concerned about the invalid SQL right now. > 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 |
From: Fabio M. (JIRA) <nh...@gm...> - 2011-05-17 17:30:46
|
[ http://216.121.112.228/browse/NH-2705?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Fabio Maulo reassigned NH-2705: ------------------------------- Assignee: Fabio Maulo > 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 > 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 |
From: Fabio M. (JIRA) <nh...@gm...> - 2011-05-17 17:43:52
|
[ http://216.121.112.228/browse/NH-2705?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=21104#action_21104 ] Fabio Maulo commented on NH-2705: --------------------------------- Ok, but take care with polymorphic queries (asking for the base type shared by component and entity). > 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 > 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 |
From: Fabio M. (JIRA) <nh...@gm...> - 2011-05-17 17:45:48
|
[ http://216.121.112.228/browse/NH-2705?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Fabio Maulo resolved NH-2705. ----------------------------- Resolution: Fixed Fix Version/s: 3.2.0Beta1 > 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 |
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 |
From: Fabio M. (JIRA) <nh...@gm...> - 2011-05-18 14:07:52
|
[ http://216.121.112.228/browse/NH-2705?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Fabio Maulo reopened NH-2705: ----------------------------- Assignee: (was: Fabio Maulo) > 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 |
From: Fabio M. (JIRA) <nh...@gm...> - 2011-05-18 14:08:00
|
[ http://216.121.112.228/browse/NH-2705?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Fabio Maulo updated NH-2705: ---------------------------- Fix Version/s: (was: 3.2.0Beta1) > 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 |
From: Fabio M. (JIRA) <nh...@gm...> - 2011-05-18 14:08:07
|
[ http://216.121.112.228/browse/NH-2705?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Fabio Maulo closed NH-2705. --------------------------- Resolution: Won't Fix > 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 |