In using Fluent NHibernate, I can't seem to find a good explanation of when you use the cascading option on the References side vs. the HasMany side.
What's the difference (if any) in mapping the following...
References(...).Cascade.All();
vs
HasMany(...).Cascade.All();
My question stems from a problem when saving a parent (root) entity. Once it's saved, I want to insure that all child objects are also persisted.
Fluent NHibernate offers an alternative to NHibernate's standard XML mapping files. Rather than writing XML documents, you write mappings in strongly typed C# code. This allows for easy refactoring, improved readability and more concise code.
You put the cascade on the side that you are saving.
If you save the parent and want to cascade to the children, put the cascade mapping on the parent.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With