in the mapping file for Content60 class:
Code:
<many-to-one name="Policy" class="Entriq.Security.BusinessObject.Policy60, Entriq.Security.BusinessObject">
<column name="PolicyRef" sql-type="bigint" not-null="true"/>
</many-to-one>
the column PolicyRef is not-null in database. This cannot be changed.
Code:
[Test]
public void TestSaveDefPolicy()
{
BusinessSession.BeginTransaction();
Content60 cContent = BusinessSession.ContentManager.Get(TestParameters.crmId,TestParameters.accountId,TestParameters.contentId);
[b]cContent.Policy = null;[/b] // here we would like the PolicyRef column to equal "0", and not "null"
cContent.ContentURL = "http://www.google.com?id=" + DateTime.Now.Ticks;
cContent.Save();
BusinessSession.CommitTransaction();
}
correctly throws the following exception:
Entriq.MDS.Tests.Defects.SaveContentWithNullPolicy.TestSaveDefPolicy : NHibernate.PropertyValueException : not-null property references a null or transient value: Entriq.Security.BusinessObject.Content60.Policy
My question is as follows: how can I modify this scenario so that NHibernate will set the PolicyRef column to 0 when we set the Policy property to null?
Any help with how to achieve this in nhibernate is greatly appreciated.