|
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
|