i have a self join employees entity class with id,name and ref columns that has relation with it self. i want to create new instance of that and persist it to db.
at first i created an instance of Employee class and named it manager. then i fetched a record from Employee table with these values: Id = 1, Name = "A", RefId = null
and set those values to manager object. after that i created an instance of Employee class again
and set it's properties value like this:
emp.Name = "B", emp.Ref = manager.
finally i persisted it by using base.Add(resource) method. at that time Nhibernate raised the following error:
"object references an unsaved transient instance save the transient instance before flushing".
this is mapping file contents:
<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 to solve this error. thx