The error looks like this:
----> NHibernate.HibernateException : not-null property references a null or transient value: EmployeePayment, Payroll
at NHibernate.Impl.SessionImpl.SaveWithGeneratedIdentifier(Object obj, CascadingAction action, Object anything)
The offending property is in a many to one relationship, Many payments to one payroll. This worked in .71 but with .84 I get the above error. In this case, the payroll and associated payments are all created outside of a session, then the session saveorupdate is called on the payroll (parent) instance. I have verified the payment has a reference to the correct payroll, and that the payroll has the correct unsaved value for id. It seems that the code is trying to save the payment before the parent payroll is saved. Suggestions?
The payment def (employee payment is a subclass)
Code:
<class name="PayrollDomain.Payroll.Payment, PayrollDomain" table="Payment">
<id name="Id" access="nosetter.camelcase-underscore" column="Id" type="Int32" unsaved-value="0">
<generator class="identity" />
</id>
<discriminator column="PaymentType" type="String" />
<many-to-one name="Payroll" class="PayrollDomain.Payroll.Payroll, PayrollDomain" column="PayrollId"
cascade="none" not-null="true" />
The payroll def
Code:
<class name="PayrollDomain.Payroll.Payroll, PayrollDomain" table="Payroll">
<id name="Id" access="nosetter.camelcase-underscore" column="Id" type="Int32" unsaved-value="0">
<generator class="identity" />
</id>
<snip>
<bag name="_employeePayments" access="field" cascade="all" inverse="true">
<key column="PayrollId" />
<one-to-many class="PayrollDomain.Payroll.EmployeePayment, PayrollDomain" />
</bag>