I have the following model:
Organization (root entity) (identified by Guid)
-ContactInformation (related entity to Organization)
--Address (related entity to ContactInformation)
When I try to save Organization using NHibernate, the ContactInformation entity and it's related Address are saved perfectly but the root entity Organization is not persisted to the underlying storage.
I'm pulling my hair out trying to figure out why. There is no exception when I call save and after calling save if I check the Organization's key field in the entity it is set with a new Guid just as I would expect if the save action worked but when I check in the database it is not there.
example code for save
Code:
ISession session = factory.OpenSession();
session.SaveOrUpdate(organization);
here is my mapping file
Code:
<?xml version="1.0"?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="RELink.Library.Domain" assembly="RELink.Library">
<class name="Organization" table="Organization" lazy="true">
<id name="Id" unsaved-value="00000000-0000-0000-0000-000000000000" access="field.camelcase">
<column name="OrganizationId" />
<generator class="guid">
</generator>
</id>
<many-to-one name="ContactInformation" column="ContactInformationId" class="ContactInformation" cascade="all-delete-orphan" access="field.camelcase" />
<property name="dateCreated" access="field" />
</class>
<class name="ContactInformation" table="ContactInformation" lazy="true">
<id name="Id" type="System.Int64" unsaved-value="0" access="field.camelcase">
<column name="ContactInformationId" />
<generator class="native"></generator>
</id>
<property name="CompanyName" />
<property name="FirstName" />
<many-to-one name="Address" column="AddressId" access="field.camelcase" class="Address" cascade="all-delete-orphan" />
</class>
<class name="Address" table="Address" lazy="true">
<id name="Id" type="System.Int64" unsaved-value="0" access="field.camelcase">
<column name="AddressId"/>
<generator class="native"></generator>
</id>
<property name="Number" />
</class>
</hibernate-mapping>