Hi, I have 2 tables, user and userprofile, both with almost identical fields. user table references userprofile table by primary key ID. My requirement is that on click of a button I need to dump user table record to userprofile table record. Now for a particular user table, if there is a corresponding userprofile entry, I am successfully able to dump the data, but if there is no record in userprofile table then I need to create a new record in it. My problem is that I am able to update the data when the record is present in userprofile table, but in the case wherein I have to create a new record I get the below error "object references an unsaved transient instance - save the transient instance before flushing".
Code:
<class name="User">
<id name="ID" type="Int32">
<generator class="native" />
</id>
<many-to-one name="Pid" class="UserProfile" />
</class>
UserProfile is another table and Pid above references the Primary key ID of UserProfile table. I tried using cascade="save-update" but it gives me the same error.