From: <rbe...@pt...> - 2011-06-23 21:50:37
|
ISession.Merge with two circularly cascaded child collections ------------------------------------------------------------- Key: NH-2775 URL: http://216.121.112.228/browse/NH-2775 Project: NHibernate Issue Type: Bug Components: Core Affects Versions: 3.2.0Beta2 Reporter: rbe...@pt... Priority: Major When I merge an object that has two circularly cascaded child collections, and I've deleted a single item from both collections, all items are deleted from the database and the merge result is correct. This also means that the merge result is inconsistent with the database. In short, the model: Product has many Orders, which have many OrderItems. OrderItem has many ChildOrderItems. The process: Product has one Order with two OrderItems, one of which is a child OrderItem (we'll call it childOrderItem) the other of which is the parent OrderItem (orderItem). The following will cause the behavior: order.OrderItems.Remove(childOrderItem); orderItem.ChildOrderItems.Remove(childOrderItem); Product product = (Product)session.Merge(detachedProduct); Expected: order.OrderItems will have one item (orderItem) and orderItem will have no child items. The merge result (product) should be representative of what's in the database. Expected SQL: UPDATE [Order] DELETE [OrderItem] Actual: order.OrderItems has one item (orderItem) and orderItem has no child items. The merge result (product) is NOT representative of what's in the database. Actual SQL: UPDATE [Order] DELETE [OrderItem] DELETE [OrderItem] See the attached test. I've just pulled from trunk and tested the project against that version (rev5968). I've looked through the merge code, and am not familiar enough, nor do I have the time needed to become familiar right now, so I have no patch (sorry). -- 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: <rbe...@pt...> - 2011-06-23 22:00:39
|
[ http://216.121.112.228/browse/NH-2775?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] rbe...@pt... updated NH-2775: --------------------------------------- Attachment: nhibernate-test-lite.7z Failing test. > ISession.Merge with two circularly cascaded child collections > ------------------------------------------------------------- > > Key: NH-2775 > URL: http://216.121.112.228/browse/NH-2775 > Project: NHibernate > Issue Type: Bug > Components: Core > Affects Versions: 3.2.0Beta2 > Reporter: rbe...@pt... > Priority: Major > Attachments: nhibernate-test-lite.7z > > > When I merge an object that has two circularly cascaded child collections, and I've deleted a single item from both collections, all items are deleted from the database and the merge result is correct. This also means that the merge result is inconsistent with the database. > In short, the model: > Product has many Orders, which have many OrderItems. > OrderItem has many ChildOrderItems. > The process: > Product has one Order with two OrderItems, one of which is a child OrderItem (we'll call it childOrderItem) the other of which is the parent OrderItem (orderItem). > The following will cause the behavior: > order.OrderItems.Remove(childOrderItem); > orderItem.ChildOrderItems.Remove(childOrderItem); > Product product = (Product)session.Merge(detachedProduct); > Expected: > order.OrderItems will have one item (orderItem) and orderItem will have no child items. The merge result (product) should be representative of what's in the database. > Expected SQL: > UPDATE [Order] > DELETE [OrderItem] > Actual: > order.OrderItems has one item (orderItem) and orderItem has no child items. The merge result (product) is NOT representative of what's in the database. > Actual SQL: > UPDATE [Order] > DELETE [OrderItem] > DELETE [OrderItem] > See the attached test. I've just pulled from trunk and tested the project against that version (rev5968). > I've looked through the merge code, and am not familiar enough, nor do I have the time needed to become familiar right now, so I have no patch (sorry). -- 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-06-25 17:34:51
|
[ http://216.121.112.228/browse/NH-2775?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=21324#action_21324 ] Fabio Maulo commented on NH-2775: --------------------------------- very bad mapping (in general) with an error on ChildOrderItems: the key-column should be "ParentOrderItemId" and not "OrderItemId". > ISession.Merge with two circularly cascaded child collections > ------------------------------------------------------------- > > Key: NH-2775 > URL: http://216.121.112.228/browse/NH-2775 > Project: NHibernate > Issue Type: Bug > Components: Core > Affects Versions: 3.2.0Beta2 > Reporter: rbe...@pt... > Priority: Major > Attachments: nhibernate-test-lite.7z > > > When I merge an object that has two circularly cascaded child collections, and I've deleted a single item from both collections, all items are deleted from the database and the merge result is correct. This also means that the merge result is inconsistent with the database. > In short, the model: > Product has many Orders, which have many OrderItems. > OrderItem has many ChildOrderItems. > The process: > Product has one Order with two OrderItems, one of which is a child OrderItem (we'll call it childOrderItem) the other of which is the parent OrderItem (orderItem). > The following will cause the behavior: > order.OrderItems.Remove(childOrderItem); > orderItem.ChildOrderItems.Remove(childOrderItem); > Product product = (Product)session.Merge(detachedProduct); > Expected: > order.OrderItems will have one item (orderItem) and orderItem will have no child items. The merge result (product) should be representative of what's in the database. > Expected SQL: > UPDATE [Order] > DELETE [OrderItem] > Actual: > order.OrderItems has one item (orderItem) and orderItem has no child items. The merge result (product) is NOT representative of what's in the database. > Actual SQL: > UPDATE [Order] > DELETE [OrderItem] > DELETE [OrderItem] > See the attached test. I've just pulled from trunk and tested the project against that version (rev5968). > I've looked through the merge code, and am not familiar enough, nor do I have the time needed to become familiar right now, so I have no patch (sorry). -- 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: <rbe...@pt...> - 2011-06-25 21:50:49
|
[ http://216.121.112.228/browse/NH-2775?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=21326#action_21326 ] rbe...@pt... commented on NH-2775: -------------------------------------------- Oh my goodness - thanks for that! I ended up porting a damn typo into the repro! You say that the mapping is "very bad (in general)" - is there something other than the wrong key-column that you would change? > ISession.Merge with two circularly cascaded child collections > ------------------------------------------------------------- > > Key: NH-2775 > URL: http://216.121.112.228/browse/NH-2775 > Project: NHibernate > Issue Type: Bug > Components: Core > Affects Versions: 3.2.0Beta2 > Reporter: rbe...@pt... > Priority: Major > Attachments: nhibernate-test-lite.7z > > > When I merge an object that has two circularly cascaded child collections, and I've deleted a single item from both collections, all items are deleted from the database and the merge result is correct. This also means that the merge result is inconsistent with the database. > In short, the model: > Product has many Orders, which have many OrderItems. > OrderItem has many ChildOrderItems. > The process: > Product has one Order with two OrderItems, one of which is a child OrderItem (we'll call it childOrderItem) the other of which is the parent OrderItem (orderItem). > The following will cause the behavior: > order.OrderItems.Remove(childOrderItem); > orderItem.ChildOrderItems.Remove(childOrderItem); > Product product = (Product)session.Merge(detachedProduct); > Expected: > order.OrderItems will have one item (orderItem) and orderItem will have no child items. The merge result (product) should be representative of what's in the database. > Expected SQL: > UPDATE [Order] > DELETE [OrderItem] > Actual: > order.OrderItems has one item (orderItem) and orderItem has no child items. The merge result (product) is NOT representative of what's in the database. > Actual SQL: > UPDATE [Order] > DELETE [OrderItem] > DELETE [OrderItem] > See the attached test. I've just pulled from trunk and tested the project against that version (rev5968). > I've looked through the merge code, and am not familiar enough, nor do I have the time needed to become familiar right now, so I have no patch (sorry). -- 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-06-26 12:58:05
|
[ http://216.121.112.228/browse/NH-2775?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=21330#action_21330 ] Fabio Maulo commented on NH-2775: --------------------------------- does it work with the fix ? > ISession.Merge with two circularly cascaded child collections > ------------------------------------------------------------- > > Key: NH-2775 > URL: http://216.121.112.228/browse/NH-2775 > Project: NHibernate > Issue Type: Bug > Components: Core > Affects Versions: 3.2.0Beta2 > Reporter: rbe...@pt... > Priority: Major > Attachments: nhibernate-test-lite.7z > > > When I merge an object that has two circularly cascaded child collections, and I've deleted a single item from both collections, all items are deleted from the database and the merge result is correct. This also means that the merge result is inconsistent with the database. > In short, the model: > Product has many Orders, which have many OrderItems. > OrderItem has many ChildOrderItems. > The process: > Product has one Order with two OrderItems, one of which is a child OrderItem (we'll call it childOrderItem) the other of which is the parent OrderItem (orderItem). > The following will cause the behavior: > order.OrderItems.Remove(childOrderItem); > orderItem.ChildOrderItems.Remove(childOrderItem); > Product product = (Product)session.Merge(detachedProduct); > Expected: > order.OrderItems will have one item (orderItem) and orderItem will have no child items. The merge result (product) should be representative of what's in the database. > Expected SQL: > UPDATE [Order] > DELETE [OrderItem] > Actual: > order.OrderItems has one item (orderItem) and orderItem has no child items. The merge result (product) is NOT representative of what's in the database. > Actual SQL: > UPDATE [Order] > DELETE [OrderItem] > DELETE [OrderItem] > See the attached test. I've just pulled from trunk and tested the project against that version (rev5968). > I've looked through the merge code, and am not familiar enough, nor do I have the time needed to become familiar right now, so I have no patch (sorry). -- 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 |