I've spent some time investigating the use of <timestamp> in the mapping file which doesn't appear to work because NHibernate uses the DateTime type to map to the TimeStamp field. This then causes errors when attempting to update the data. I've tried using DateTime, Int32 and Byte[] for the property but none of these work (I get casting errors). I've looked at the documentation and these forums and can find no solution to this problem.
As an alternative I'm reading the timestamp value in via a <property> and trying to add a condition on the update (using CreateCriteria) so that it would appear something like
Code:
UPDATE table
SET x = y
WHERE id = <id>
and timestamp = <original timestamp>
Hopefully this would then only do the update if the original timestamp value has not changed. However doing a trace on the resulting SQL I can see that the timestamp line never gets added. Does this mean the CreateCriteria method only works on data retrievals and not updates? Is there
any way of doing this at all or does it not fit in with the methodology?