David
David

Reputation: 16120

NHibernate cascade update/insert

I have a Case class which exposes a Person object as follows:

public class Case
{
  public virtual Person Deceased {get;set;}
}

I have a PersonalAsset class which also exposes a Person:

public class PersonalAsset
{
  public virtual Person Owner {get;set;}
}

Assuming I write the following code within an ISession:

Case case = new Case();
Person deceased = new Person();
case.Deceased = deceased;
PersonalAsset asset = new PersonalAsset();
asset.Owner = deceased;
session.SaveOrUpdate(case);

Is there any mapping configuration which will save the PersonalAsset automatically? Or do I need to call session.Save(asset) as well?

Thanks

David

Upvotes: 0

Views: 388

Answers (1)

Shane Courtrille
Shane Courtrille

Reputation: 14097

Without a reference between them you would need to save things manually. From a modeling point of view are you maybe missing an aggregate root that owns both of these things?

Upvotes: 1

Related Questions