Hi !
Sorry, if i am asking about a trivial problem.
I tried to cascade update parent/child elements, il got the message below:
SQL insert, update or delete failed (expected affected row count: 1, actual affected row count: 0). Possible causes: the row was modified or deleted by another user, or a trigger is reporting misleading row count.
I don't know if it's a facility problem, or anything else.
Thanks in advance for your help.
Code:
Department dept = session.Load(typeof(Department), 1)) as Department;
Employee emp = new Employee();
emp.DeptDepartment = dept;
emp.Name = "my name";
emp.Sex = 1;
dept.EmployeesDept.Add(emp);
session.Save(dept);
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="Com.Benday.BugTracker.Business.Department, Com.Benday.BugTracker.Business" table="Department">
<id name="Id" type="Int32" unsaved-value="null">
<column name="Id" length="4" sql-type="int" not-null="true" unique="true" index="PK_Department"/>
<generator class="native" />
</id>
<property name="Name" type="String">
<column name="Name" length="50" sql-type="nvarchar" not-null="true"/>
</property>
<bag name="EmployeesDept" inverse="true" lazy="true" cascade="all">
<key column="DeptId"/>
<one-to-many class="Com.Benday.BugTracker.Business.Employee, Com.Benday.BugTracker.Business"/>
</bag>
</class>
</hibernate-mapping>
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="Com.Benday.BugTracker.Business.Employee, Com.Benday.BugTracker.Business" table="Employee">
<id name="Id" type="Int32" unsaved-value="null">
<column name="Id" length="4" sql-type="int" not-null="true" unique="true" index="PK_Employee"/>
<generator class="native" />
</id>
<property name="Name" type="String">
<column name="name" length="50" sql-type="nvarchar" not-null="true"/>
</property>
<property name="Sex" type="Single">
<column name="sex" length="4" sql-type="real" not-null="true"/>
</property>
<many-to-one name="DeptDepartment" class="Com.Benday.BugTracker.Business.Department, Com.Benday.BugTracker.Business">
<column name="DeptId" length="4" sql-type="int" not-null="true"/>
</many-to-one>
</class>
</hibernate-mapping>
Tony