Hi,
I have had an issue with code that worked in RC1 that now exhibits different behaviour under RC3.
Specifically, the result of the "version unsaved value" in the AbstractEntityPersister( PersistentClass model, ISessionFactoryImplementor factory ) method is different.
In RC1 I get a unsavedVersionValue.Value = null.
In RC3 I get a unsavedVersionValue.Value = int.MinValues.
So what does this mean for me? Well given these mappings:
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" namespace="XXX.BusinessEntities" assembly="XXX">
<class name="LicenceDetail" table="LicenceDetails" dynamic-update="true">
<id name="Id" column="LD_ID" type="Int32" >
<generator class="identity" />
</id>
<!-- Standard Audit Properties -->
<version name="RowVersion" column="RowVersion" type="Int32" />
<property name="CreationUser" column="CreationUser" type="String" />
<property name="CreationDateTime" column="CreationDateTime" type="DateTime" />
<property name="LastUpdateUser" column="LastUpdateUser" type="String" />
<property name="LastUpdateDateTime" column="LastUpdateDateTime" type="DateTime" />
<!-- End -->
<property name="Status" column="LD_Status" type="String" />
<property name="DateIssued" column="LD_dateIssued" type="DateTime" />
<property name="DateSurrendered" column="LD_dateSurrendered" type="DateTime" />
<property name="DateTransferred" column="LD_dateTransferred" type="DateTime" />
<property name="DateSuspFrom" column="LD_dateSuspFrom" type="DateTime" />
<property name="DateSuspTo" column="LD_dateSuspTo" type="DateTime" />
<property name="MachinesApproved" column="LD_machinesApproved" type="Int16" />
</class>
</hibernate-mapping>
and
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" namespace="XXX.BusinessEntities" assembly="XXX">
<class name="LinkedLicence" table="LinkedLicences" dynamic-update="true">
<id name="Id" column="LNK_ID" type="Int32">
<generator class="identity" />
</id>
<!-- Standard Audit Properties -->
<version name="RowVersion" column="RowVersion" type="Int32" />
<property name="CreationUser" column="CreationUser" type="String" />
<property name="CreationDateTime" column="CreationDateTime" type="DateTime" />
<property name="LastUpdateUser" column="LastUpdateUser" type="String" />
<property name="LastUpdateDateTime" column="LastUpdateDateTime" type="DateTime" />
<!-- End -->
<many-to-one name="LicenceDetail" column="LNK_LD_ID_Parent" insert="true" update="true" />
</class>
The following code used to work in RC1:
Code:
LinkedLicence linked = new LinkedLicence();
LicenceDetail detail = new LicenceDetail();
detail.Id = 7856;
linked.LicenceDetail = detail;
session.FlushMode = FlushMode.Commit;
session.BeginTransaction();
session.SaveOrUpdate(linked);
session.Transaction.Commit();
It resulted in an insert statement that included the foreign key 7856 for the column LNK_LD_ID_Parent.
However with RC3, the LNK_LD_ID_Parent resolves to NULL because Hibernate thinks that it is unsaved.
So, is this a bug, design feature or what can I do to resolve this issue?
BTW, my RowVersion property defaults to int.MinValues in my class.
I can work around the issue by specifying a
Code:
detail.RowVersion = 0;
Which results in Hibernate thinking I have a saved entity and the key is used as per RC1.
Cheers,
Mike :shock: