Hi guys,
having a real hard time with this so would appreciate some help. I am trying to set up a one-to-one association and save it out but cannot get it to work. I have one table with the following:
TABLE PROFILESProfileId (PK)
Name
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="" assembly="">
<class name="Profile, Assembly" table="Profile" lazy="true">
<id name="Id" column="ProfileId">
<generator class="native" />
</id>
<one-to-one name="Setting" class="Setting" cascade="save-update" />
<property Name="Name" column="name"/>
</class>
</hibernate-mapping>
SETTINGS TABLEProfileId (FK - to profiles table)
Setting
Code:
Hi guys,
having a real hard time with this so would appreciate some help. I am trying to set up a one-to-one association and save it out but cannot get it to work. I have one table with the following:
[b]TABLE PROFILES[/b]
ProfileId (PK)
Name
[code]
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="" assembly="">
<class name="Profile, Assembly" table="Profile" lazy="true">
<id name="Id" column="ProfileId">
<generator class="native" />
</id>
<one-to-one name="Setting" class="Setting" cascade="save-update" />
<property Name="Name" column="name"/>
</class>
</hibernate-mapping>
[/code]
[b]PROFILESETTINGS TABLE[/b]
ProfileId (FK - to profiles table)
Setting
[code]
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="" assembly="">
<class name="ProfileSetting, assembly" table="ProfileSetting" lazy="true">
<id name="Id" column="ProfileId">
<generator class="assigned"></generator>
</id>
<property name="Setting" column="Setting" />
<one-to-one name="Profile" class="Profile" constrained="true" />
</class>
</hibernate-mapping>
whenever I do the following:
Profile prof = new Profile;
prof.Setting = new ProfileSetting();
session.Save();
I get a null identifier and I am assuming its not assigning the setting an id (works ok If i remove the settings class) has anyone got an example please on how to set this type of scenario up?
Thanks
Mocksy.