object references an unsaved transient instance
Posted
by developer
on Stack Overflow
See other posts from Stack Overflow
or by developer
Published on 2010-03-17T18:47:23Z
Indexed on
2010/03/17
18:51 UTC
Read the original article
Hit count: 174
nhibernate-mapping
|c#
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. 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 by dumping all the data. 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".
`<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.
© Stack Overflow or respective owner