Disable Select after insert/update for Version property

84 views
Skip to first unread message

Greg

unread,
Apr 19, 2012, 12:48:33 PM4/19/12
to nhusers
I use Versioning with SQL Server with a rowversion(timestamp) column.
In Entity Framework one can disable the select after insert/update
with a simple flag.
But I couldn't figure out how to do it in NH. This fact disables
batching completely and slows down things considerably.

I don't care what's the updated rowversion value after the insert/
update.
Any idea how to disable the select after insert/update with a db
generated rowversion column?

This is my current mapping:
<version name="RowStamp" type="Byte[]" insert="false"
generated="always" unsaved-value="undefined"> <column name="RowStamp"
not-null="true" sql-type="rowversion" length="8"/> </version>

If I remove generated, I get some null pointer exception somewhere
deep inside NH.

What kind of mapping could I use to disable the select after insert/
update, or is there some other config option inside NH for that.

Alex Vilela

unread,
Apr 24, 2012, 11:05:04 AM4/24/12
to nhu...@googlegroups.com
Have you tried a version column with the default type, an integer?

NHibernate needs to know the version value to update it's caches. 
On a DB controlled timestamp column the extra select is required.
With an integer column, NH calculates the field before the update and no further select is required.

Greg

unread,
Apr 26, 2012, 10:52:56 AM4/26/12
to nhusers
The hack for me that seems to work is not mapping the rowversion
column for bulk insert/update operations. They happen overnight in a
different process. And leave it mapped for UI where it's mostly needed
because more than on user access the the app via UI. Also imports must
have the final say, and users should not override imported data with
stale data from the UI.

I am not sure about using int, how that works if you write from
different processes (using NH) to same db?
Reply all
Reply to author
Forward
0 new messages