Tuesday, February 28, 2006

NHibernate debug

NHibernate “Can’t save to null “ adoexception
When you failed to maintain your relationship between entities correctly, and there is a cascade saveupdate, you will probably see this error.
<class husbande>
<one-to-one class=wife cascading=save-update>
….
Husband tom = new Husband();
Wife jane = new Wife();
tom.wife = jane;
sess.SaveOrUpdate(tom)

since you missed the  jane.husband = tom;
you will get that err.