Fixing "deleted object would be re-saved" In NHibernate

One of the troublesome problem of NHibernate(maybe also in Hibernate) is to solve "deleted object would be re-saved" error. The cause of this problem varies but there are certain steps that can be useful when fixing  it:
1)If there is a hasMany relation, try to use the following in your mapping file:
HasMany(x => x.users).KeyColumn("idUser").Cascade.Delete().Inverse().AsBag();

2)Be sure that there is no remaning list that contains deleted item in your session.
shoppingItem.ownedUsers= null;

No comments:

Post a Comment