I have my own class of employee entities with identifiers, names, and links that are relevant to it. I want to create a new instance of this and save it in db.
I first created an instance of the Employee class and called it the manager. then I extracted an entry from the Employee table with these values: Id = 1, Name = "A", RefId = null and set these values ββfor the manager object. after that I created an instance of the Employee class again
and set the property value as follows: emp.Name = "B", emp.Ref = manager. finally, I saved it using the base.Add (resource) method. at that time, Nhibernate raised the following error: "the object refers to an unsaved transient instance, storing a temporary instance before flushing."
this is the contents of the mapping file:
<class name="Employee" table="Employee" schema="dbo" optimistic-lock="none" lazy="true"> <id name="Id" access="property" column="Id"> <generator class="identity" /> </id> <property name="Name" type="String" column="Name" length="50" /> <property name="RefId" type="Int64" column="RefId" insert="false" update="false"/> <many-to-one name="Ref" class="Employee" column="RefId" not-null="false" fetch="select" /> class>
please help me resolve this error. THX
source share