Adam
Adam

Reputation: 335

Fluent NHibernate Cascade - Which side?

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.

Upvotes: 20

Views: 8515

Answers (1)

mathieu
mathieu

Reputation: 31192

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.

Upvotes: 25

Related Questions