using (ISession session = TestCategory.Factory.OpenSession())
当我设置了 chilid.Id =1的时候,则出现了 Test method TestProject1.TestCategory.AddParentChild threw exception: NHibernate.HibernateException: 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.. 跟踪执行的SQL语句后,发现并不是Insert Child,而是Update Child。 当我将chilid.Id =1注释后,就正常,不过chilid.Id他用 unsaved-value="0"代替。 执行的SQL语句都是正常的。