I searched so many places and still can not find the answer I'm looking for.
I am using NHibernate 3.2 - Display by code
I have the following mapping files:
public class ParentMapping: EntityMapping<Parent> { public ParentMapping() { Set(x => x.Children, map => { map.Cascade(Cascade.All); map.Inverse(true); }, r => r.OneToMany()); } } public class ChildMapping: JoinedSubclassMapping<Child>
Cascading save works fine.
session.Save(parent) will save the children and associate them correctly.
When I try to call:
var parent = session.Get<Parent>(1); parent.Children.Clear(); session.Save(parent); or session.SaveOrUpdate(parent) or session.Update(parent)
Objects remain associated with the parent.
It was working for me by calling:
foreach(var child in parent.Children) { session.Delete(child); } parent.Children.Clear();
I was hoping there was a way to just keep the parent?
Greetings
James
source share