I have a problem with one-to-many relationships. I have the following domain classes:
public class Installation : Entity
{
pu
When you have a persistent collection with inverse="false"
, then the parent object owns the relationship and any changes to the parent's collection will be reflected in the database.
When you have a persistent collection with inverse="true"
, then the child object owns the relationship and any changes to the child's reference to the parent will be reflected in the database.
Because you set inverse="true"
, you will need to change the child object's reference to the parent object in order for NHibernate to pick up on it. If you wish NHibernate to pick up on the changes to the relationship whenever you add children to or remove children from the parent's collection, you must set inverse="false"
on the collection.
You have to manually set the Installation Property of an Institution, specifically,
Installation installation = TestHelper.CreateAnonymousInstallation();
Institution institution = TestHelper.CreateAnonymousInstitution();
institution.Installation = installation;
installation.Institutions.Add(institution);