From: NHibernate J. <mik...@us...> - 2006-11-29 07:51:39
|
Using Criteria to query for an item throws on Flush in some situations ---------------------------------------------------------------------- Key: NH-826 URL: http://jira.nhibernate.org/browse/NH-826 Project: NHibernate Type: Bug Components: Core Versions: 1.2.0.Beta2 Reporter: Aaron Jensen Priority: Blocker Attachments: NHibernateTest.zip The situation is best described by the attached sample project, but I will attempt to explain in words when this problem occurs. EntityA has a many-to-many to EntityB EntityB has a subclass EntityC EntityC has a one-to-many to EntityD If you create an EntityB and associate it to EntityA, then query for EntityA via Criteria (but not via HQL) then Session.Flush() will fail with: NHibernate.HibernateException: You may not dereference an collection with cascade="all-delete-orphan" at NHibernate.Impl.SessionImpl.UpdateUnreachableCollection(IPersistentCollection coll) in c:\net\nhibernate\nhibernat e\src\NHibernate\Impl\SessionImpl.cs:line 3957 at NHibernate.Impl.SessionImpl.FlushCollections() in c:\net\nhibernate\nhibernate\src\NHibernate\Impl\SessionImpl.cs: line 3802 at NHibernate.Impl.SessionImpl.FlushEverything() in c:\net\nhibernate\nhibernate\src\NHibernate\Impl\SessionImpl.cs:l ine 3090 The collection it is complaining about is a collection of EntityD objects which should never have been created in the first place. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.nhibernate.org/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |
From: NHibernate J. <mik...@us...> - 2006-11-29 07:57:39
|
[ http://jira.nhibernate.org/browse/NH-826?page=comments#action_14500 ] Aaron Jensen commented on NH-826: --------------------------------- Oops, just realized I accidentally set this as a Blocker priority, sorry about that. It is blocking us from migrating to 1.2, so I'd love to see it fixed sooner than later, but it is hardly a full-on Blocker. > Using Criteria to query for an item throws on Flush in some situations > ---------------------------------------------------------------------- > > Key: NH-826 > URL: http://jira.nhibernate.org/browse/NH-826 > Project: NHibernate > Type: Bug > Components: Core > Versions: 1.2.0.Beta2 > Reporter: Aaron Jensen > Priority: Blocker > Attachments: NHibernateTest.zip > > The situation is best described by the attached sample project, but I will attempt to explain in words when this problem occurs. > EntityA has a many-to-many to EntityB > EntityB has a subclass EntityC > EntityC has a one-to-many to EntityD > If you create an EntityB and associate it to EntityA, then query for EntityA via Criteria (but not via HQL) then Session.Flush() will fail with: > NHibernate.HibernateException: You may not dereference an collection with cascade="all-delete-orphan" > at NHibernate.Impl.SessionImpl.UpdateUnreachableCollection(IPersistentCollection coll) in c:\net\nhibernate\nhibernat > e\src\NHibernate\Impl\SessionImpl.cs:line 3957 > at NHibernate.Impl.SessionImpl.FlushCollections() in c:\net\nhibernate\nhibernate\src\NHibernate\Impl\SessionImpl.cs: > line 3802 > at NHibernate.Impl.SessionImpl.FlushEverything() in c:\net\nhibernate\nhibernate\src\NHibernate\Impl\SessionImpl.cs:l > ine 3090 > The collection it is complaining about is a collection of EntityD objects which should never have been created in the first place. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.nhibernate.org/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |
From: NHibernate J. <mik...@us...> - 2006-12-05 07:33:33
|
[ http://jira.nhibernate.org/browse/NH-826?page=comments#action_14530 ] Ayende Rahien commented on NH-826: ---------------------------------- The issue is on SessionImpl, line 3396, and the problem is that a collection entry is loaded, even though there isn't any values (or owner) for it. Not sure where to find the issue. Here is the generated SQL; SELECT this_.Id as Id0_2_, activities2_.ActivitySetId as Activity1___4_, activityen3_.Id as ActivityId4_, activityen3_.Id as Id2_0_, activityen3_.ActivityType as Activity2_0_, questions4_.EvaluationActivityId as Evaluati2___5_, questions4_.Id as Id5_, questions4_.Id as Id3_1_ FROM co_activity_set this_ left outer join co_activity_set_membership activities2_ on this_.Id=activities2_.ActivitySetId left outer join co_activity activityen3_ on activities2_.ActivityId=activityen3_.Id left outer join co_question questions4_ on activityen3_.Id=questions4_.EvaluationActivityId WHERE this_.Id = 1 > Using Criteria to query for an item throws on Flush in some situations > ---------------------------------------------------------------------- > > Key: NH-826 > URL: http://jira.nhibernate.org/browse/NH-826 > Project: NHibernate > Type: Bug > Components: Core > Versions: 1.2.0.Beta2 > Reporter: Aaron Jensen > Priority: Blocker > Attachments: NHibernateTest.zip > > The situation is best described by the attached sample project, but I will attempt to explain in words when this problem occurs. > EntityA has a many-to-many to EntityB > EntityB has a subclass EntityC > EntityC has a one-to-many to EntityD > If you create an EntityB and associate it to EntityA, then query for EntityA via Criteria (but not via HQL) then Session.Flush() will fail with: > NHibernate.HibernateException: You may not dereference an collection with cascade="all-delete-orphan" > at NHibernate.Impl.SessionImpl.UpdateUnreachableCollection(IPersistentCollection coll) in c:\net\nhibernate\nhibernat > e\src\NHibernate\Impl\SessionImpl.cs:line 3957 > at NHibernate.Impl.SessionImpl.FlushCollections() in c:\net\nhibernate\nhibernate\src\NHibernate\Impl\SessionImpl.cs: > line 3802 > at NHibernate.Impl.SessionImpl.FlushEverything() in c:\net\nhibernate\nhibernate\src\NHibernate\Impl\SessionImpl.cs:l > ine 3090 > The collection it is complaining about is a collection of EntityD objects which should never have been created in the first place. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.nhibernate.org/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |
From: NHibernate J. <mik...@us...> - 2006-12-05 07:41:31
|
[ http://jira.nhibernate.org/browse/NH-826?page=all ] Sergey Koshcheyev updated NH-826: --------------------------------- Fix Version: 1.2.0.CR1 Priority: Major (was: Blocker) > Using Criteria to query for an item throws on Flush in some situations > ---------------------------------------------------------------------- > > Key: NH-826 > URL: http://jira.nhibernate.org/browse/NH-826 > Project: NHibernate > Type: Bug > Components: Core > Versions: 1.2.0.Beta2 > Reporter: Aaron Jensen > Fix For: 1.2.0.CR1 > Attachments: NHibernateTest.zip > > The situation is best described by the attached sample project, but I will attempt to explain in words when this problem occurs. > EntityA has a many-to-many to EntityB > EntityB has a subclass EntityC > EntityC has a one-to-many to EntityD > If you create an EntityB and associate it to EntityA, then query for EntityA via Criteria (but not via HQL) then Session.Flush() will fail with: > NHibernate.HibernateException: You may not dereference an collection with cascade="all-delete-orphan" > at NHibernate.Impl.SessionImpl.UpdateUnreachableCollection(IPersistentCollection coll) in c:\net\nhibernate\nhibernat > e\src\NHibernate\Impl\SessionImpl.cs:line 3957 > at NHibernate.Impl.SessionImpl.FlushCollections() in c:\net\nhibernate\nhibernate\src\NHibernate\Impl\SessionImpl.cs: > line 3802 > at NHibernate.Impl.SessionImpl.FlushEverything() in c:\net\nhibernate\nhibernate\src\NHibernate\Impl\SessionImpl.cs:l > ine 3090 > The collection it is complaining about is a collection of EntityD objects which should never have been created in the first place. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.nhibernate.org/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |
From: NHibernate J. <mik...@us...> - 2006-12-29 21:45:31
|
[ http://jira.nhibernate.org/browse/NH-826?page=all ] Aaron Jensen updated NH-826: ---------------------------- Attachment: NH826.patch This patch fixes it for me. It's hacky and doesn't feel right, so I'm sure theres a more top down approach to this. Here's my side of a conversation I had with Ayende explaining the issue: (1:30:11 PM) Aaron: it's hacky (1:30:25 PM) Aaron: and i dont know if its the right solution (1:31:05 PM) Aaron: the issue is that the loadelementsfromcolleciton gets the collectionpersisters for all possible collections for an entity (including it's subclasses) (1:31:38 PM) Aaron: so if an entity is of the base class, it creates a collection that belongs to the subclass (1:31:46 PM) Aaron: and it's automatically unreferenced (1:31:49 PM) Aaron: because it can't be referenced (1:32:13 PM) Aaron: ok, let me back up... you have a subclass (1:32:19 PM) Aaron: and you have a base class (1:32:26 PM) Aaron: sub has a collection (1:32:29 PM) Aaron: base does not (1:32:36 PM) Aaron: then you have a container class, that has a collection of base (1:32:48 PM) Aaron: you get a row from the resultset (1:32:56 PM) Aaron: and you've got to hydrate all the collections it contains (1:33:18 PM) Aaron: so, if you get container fetch base fetch collection (1:33:30 PM) Aaron: or just container join base fetch collection (1:34:12 PM) Aaron: so the collection persister for the collection is there, and it's owner is base (1:34:30 PM) Aaron: even though base does not have that collection (1:34:53 PM) Aaron: at some point the entity's type is determined.. and it's instantiated (1:34:59 PM) Aaron: so base is instantiated (1:35:04 PM) Aaron: because that's what it is, it's NOT sub (1:35:34 PM) Aaron: but the collectionpersister for the collection still exists because it doesn't know at the time it's created that it's not needed... AND it's needed later if there is a sub in the container (1:35:55 PM) Aaron: so either the set of collectionpersisters needs to change on each row based on the type (1:36:08 PM) Aaron: or we need to filter using reflection like my patch does (1:37:31 PM) Aaron: no idea how it worked in 1.0 (1:37:34 PM) Aaron: didn't look at the code (1:37:41 PM) Aaron: it may not have (1:37:49 PM) Aaron: because they changed it to fetch as default (1:37:55 PM) Aaron: so we may have never seen it > Using Criteria to query for an item throws on Flush in some situations > ---------------------------------------------------------------------- > > Key: NH-826 > URL: http://jira.nhibernate.org/browse/NH-826 > Project: NHibernate > Type: Bug > Components: Core > Versions: 1.2.0.Beta2 > Reporter: Aaron Jensen > Fix For: 1.2.0.Beta3 > Attachments: NH826.patch, NHibernateTest.zip > > The situation is best described by the attached sample project, but I will attempt to explain in words when this problem occurs. > EntityA has a many-to-many to EntityB > EntityB has a subclass EntityC > EntityC has a one-to-many to EntityD > If you create an EntityB and associate it to EntityA, then query for EntityA via Criteria (but not via HQL) then Session.Flush() will fail with: > NHibernate.HibernateException: You may not dereference an collection with cascade="all-delete-orphan" > at NHibernate.Impl.SessionImpl.UpdateUnreachableCollection(IPersistentCollection coll) in c:\net\nhibernate\nhibernat > e\src\NHibernate\Impl\SessionImpl.cs:line 3957 > at NHibernate.Impl.SessionImpl.FlushCollections() in c:\net\nhibernate\nhibernate\src\NHibernate\Impl\SessionImpl.cs: > line 3802 > at NHibernate.Impl.SessionImpl.FlushEverything() in c:\net\nhibernate\nhibernate\src\NHibernate\Impl\SessionImpl.cs:l > ine 3090 > The collection it is complaining about is a collection of EntityD objects which should never have been created in the first place. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.nhibernate.org/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |
From: NHibernate J. <mik...@us...> - 2007-01-03 11:40:28
|
[ http://jira.nhibernate.org/browse/NH-826?page=all ] Sergey Koshcheyev closed NH-826: -------------------------------- Resolution: Fixed > Using Criteria to query for an item throws on Flush in some situations > ---------------------------------------------------------------------- > > Key: NH-826 > URL: http://jira.nhibernate.org/browse/NH-826 > Project: NHibernate > Type: Bug > Components: Core > Versions: 1.2.0.Beta2 > Reporter: Aaron Jensen > Fix For: 1.2.0.Beta3 > Attachments: NH826.patch, NHibernateTest.zip > > The situation is best described by the attached sample project, but I will attempt to explain in words when this problem occurs. > EntityA has a many-to-many to EntityB > EntityB has a subclass EntityC > EntityC has a one-to-many to EntityD > If you create an EntityB and associate it to EntityA, then query for EntityA via Criteria (but not via HQL) then Session.Flush() will fail with: > NHibernate.HibernateException: You may not dereference an collection with cascade="all-delete-orphan" > at NHibernate.Impl.SessionImpl.UpdateUnreachableCollection(IPersistentCollection coll) in c:\net\nhibernate\nhibernat > e\src\NHibernate\Impl\SessionImpl.cs:line 3957 > at NHibernate.Impl.SessionImpl.FlushCollections() in c:\net\nhibernate\nhibernate\src\NHibernate\Impl\SessionImpl.cs: > line 3802 > at NHibernate.Impl.SessionImpl.FlushEverything() in c:\net\nhibernate\nhibernate\src\NHibernate\Impl\SessionImpl.cs:l > ine 3090 > The collection it is complaining about is a collection of EntityD objects which should never have been created in the first place. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.nhibernate.org/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |