Hiya,
I am seeing different behaviours between using SaveOrUpdate() or SaveOrUpdateCopy() when I use a version number in my mappnig.
Given the following mapping:
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" namespace="XXX.BusinessEntities" assembly="XXX">
<class name="ComplianceCriteria" table="ComplianceCriteria" dynamic-update="true">
<id name="Id" column="CC_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 -->
</class>
</hibernate-mapping>
What I am finding is that the RowVersion property is not updated when I use SaveOrUpdateCopy(). It's as though I lose the reference to the entity through my layers somehow. If this was true though, then I would expect that SaveOrUpdate would exhibit the same behaviour - which it does not - the RowVersion is updated correctly.
Further to this if I run it outside my HTTP handler like this (which is basically what my handler is doing):
Code:
Dim cc As New ComplianceCriteria
Dim session As ISession = _sessionFactory.OpenSession()
cc = CType(session.Load(cc.GetType(), 2), ComplianceCriteria)
session.FlushMode = FlushMode.Commit
session.BeginTransaction()
session.SaveOrUpdateCopy(cc)
session.Transaction.Commit()
session.Close()
Then the RowVersion is updated OK.
So I am kinda confused. Can anyone shed some light on this?
Cheers,
Mike :D