Cascading Collections Using NHibernate StatelessSession

What is the appropriate way for bulk inserted objects that contain collections of other objects ( HasMany ) using stateless sessions?

eg. The parent class is displayed as follows:

 class ParentMap : ClassMap<Parent> { public ParentMap() { Id(x => x.Id) .GeneratedBy.Increment(); HasMany(x => x.ChildNodes) .KeyColumns.Add("Parent_id") .Cascade.All(); } } 

A stateless session ignores the Cascade parameter, so child nodes are not automatically saved. I myself could iterate through the collection, but then I can’t establish a relationship because the Parent_id column Parent_id not exist as a property that I could write.

Did I miss something?

+6
c # nhibernate fluent-nhibernate cascade
source share
1 answer

You need to either create the Parent property in the child class, or use a state session.

+5
source share

All Articles