Hi,
It seems that SQL Server "rowversion" columns (8-byte value mapped to byte[]) cannot be used as version columns in NHibernate 1.2.0GA.
The documentation clearly states that
Quote:
Version numbers may be of type Int64, Int32, Int16, Ticks, Timestamp, or TimeSpan (or their nullable counterparts in .NET 2.0).
However, I couldn't find a way to map the SQL Server "rowversion" column to one of the supported types. When I try to map it to Int64:
Code:
<version column="RowVersion" name="RowVersion" type="Int64" generated="always"/>
The following exception is thrown:
Quote:
Unhandled Exception: NHibernate.ADOException: Could not cast the value in field
RowVersion1_0_ of type Byte[] to the Type Int64Type. Please check to make sure
that the mapping is correct and that your DataProvider supports this Data Type.
When I try to use the "correct" mapping to Byte[]:
Code:
<version column="RowVersion" name="RowVersion" type="Byte[]" generated="always"/>
I'm getting the following exception:
Quote:
System.InvalidCastException: Unable to cast object of type 'NHibernate.Type.BinaryType' to type 'NHibernate.Type.IVersionType'.
at NHibernate.Tuple.PropertyFactory.BuildVersionProperty(Property property, Boolean lazyAvailable)
I found the following closed feature ticket,
"Generated properties", at JIRA:
Quote:
NHibernate should be able to use database-generated properties, including timestamps (timestamp on MySQL and SQL Server, xmin on PostgreSQL, etc.)
Looking at the code, NHibernate.Type.BinaryType does not implement NHibernate.Type.IVersionType.
Is it possible to add the needed implementation to the BinaryType class?
Thanks,
Roy.