In my application I have a User class which has one and only one Settings class. A one-to-one relationship
I have a simple NHibernate mapping for a User:
/// NHibernate declarations etc
<id name="squid" type="guid">
<generator class="assigned" />
</id>
/// Properties
<one-to-one class="Settings" name="Settings" outer-join="true" cascade="save-update" />
/// Close tags & end file
And my Settings class is
/// NHibernate declarations
<id name="squid" type="guid">
<generator class="assigned" />
</id>
/// Properties, close tags & end of file
So as you can see my User is assigned a guid based from their Active Directory account (or in my unit tests, a new Guid generated by Guid.NewGuid())
Is it possible for NHibernate to magically assign the Settings GUID to be the User GUID?
As I understood your example better define
Settingsas Value object, because it does not make sense withoutUser. It’s common practice in Nhibernate usage. You can read more about this here.