This has raised its head again. (In nHibernate 2.0.0.1)
The problem occurs when the version field in the (postgres) table (an integer field) has no value.
When this field is set to zero - everything works fine.
When the db field is left with no value - the 'EntityEntry.Version' field turns out to be null. But examining the propertyValues, the value of the id field is correct (not null).
This is weird, because in my business object, the version field is being set with a value of 0, and returning 0.
The mapping entry is:-
Code:
<version name="Version" column="version" unsaved-value="0" type="Int32" access="property"/>
But that has gone through many incarnations, and none of the options worked.
The only thing that has worked is to give the field a default value.
Is this how it should be ?
The problem shows itself in DefaultFlushEntityEventListener at line 320
Code:
object nextVersion = isVersionIncrementRequired ?
Versioning.Increment(entry.Version, persister.VersionType, @event.Session) :
entry.Version; //use the current version
Thanks.