I have a one-to-one relationship between a Company class and a CompanySettings class. When I create a new Company object, (a CompanySettings object is created in Company's constructor for its Settings property), and then
SaveOrUpdate(session, companyObject)
I expect the INSERT to cascade from the Company to the CompanySettings. However, this does not happen unless I explicitly call SaveOrUpdate on the CompanySettings object as well.
Mapping files shown below:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"`>
<class name="AST.Domain.Company, AST.Domain" table="Companies">
<id name="EntityID" column="CompanyId">
<generator class="guid.comb" />
</id>
<property name="CompanyName" />
. . .
<one-to-one name="Settings" class="AST.Domain.CompanySettings, AST.Domain"
constrained="true" lazy="false" />
</class>
</hibernate-mapping>
My mapping file for the Company Settings class:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="AST.Domain.CompanySettings, AST.Domain" table="CompanySettings">
<id name="EntityID" column="CompanyId">
<generator class="foreign">
<param name="property">Company</param>
</generator>
</id>
<property name="MaxUsers" />
<one-to-one name="Company" class="AST.Domain.Company, AST.Domain" />
</class>
</hibernate-mapping>