I have this quite usual situation:
Table ORDER has a collection of ORDERDETAIL.
ORDERDETAIL has a reference to table ARTICLE.
Due to this ARTICLE has a collection of ORDERDETAILs.
If I delete a ORDER, NHibernate deletes the linked ORDERDETAILs too
(see the Cascade below),
but do not remove the deleted ORDERDETAIL row from
Article.Orderdetails collection loaded into the session.
I have to manually remove it adding the following code somewhere
before delete OrderDetail entity:
this.Article.OrderDetails.Remove(this); // this is a OrderDetail
entity object
Why NHibernate does not do this automagically?
Did I make a mistake or a misunderstanding?
Thanks,
Alessandro
Following some relevant code:
Table ORDER:
/// <summary>
/// Summary of OrderDetails.
/// </summary>
/// <value>The order details.</value>
[HasMany(typeof (OrderDetail), Table = "OrderDetail",
ColumnKey = "OrderID",
Inverse = true, Lazy = true, OrderBy = "RowNumber",
Cascade = ManyRelationCascadeEnum.AllDeleteOrphan,
Access = PropertyAccess.NosetterCamelcaseUnderscore)]
public virtual IList<OrderDetail> OrderDetails
{
get { return _orderDetails; }
Table ORDERDETAIL:
/// <summary>
/// Gets or sets the finished article.
/// </summary>
/// <value>The finished article.</value>
[BelongsTo("ArticleID")]
public virtual Article Article
{
get { return _article; }
set { _article = value; }
}
Table ARTICLE:
/// <summary>
/// Gets the order details.
/// </summary>
/// <value>The order details.</value>
[HasMany(typeof(OrderDetail), Table = "OrderDetail", ColumnKey
= "ArticleID",
Inverse = true, Lazy = true,
Cascade = ManyRelationCascadeEnum.None)]
public virtual IList<OrderDetail> OrderDetailsFinished { get;
private set; }
--
You received this message because you are subscribed to the Google Groups
"Castle Project Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/castle-project-users?hl=en.