Today I had to use an Ative Record implementation for C#: Castle Active Record. It worked verfy fine until i needed to save a one to many relationship. Then the underlying NHibernate yielded the following Exception:
StaleStateException: unexpected row count -1 expected 1
.
Googling for that Exception gave me two options: At first, turning the sql servers NOCOUNT property OFF by either sending “SET NOCOUNT OFF” or setting the appropriate property of the SQL-Server in the config dialog. Both did not work for me, as i am neither the Admin of the server nor i can send the command by hand through the many layers introduced by ActiveRecord/NHibernate.
Another possible solution was overriding the connection driver to let i send the query everytime the connection gets requested. This was proposed by the blog author of: http://www.socialanimal.com/archives/2008/03/07/nhibernate-and-nocount/. This either didn’t work for me.
But taking a look in the database suprised me! My Data was actually written! So a simply try {} catch(…) { //ignore } did the job!
SHAME ON ME FOR THAT
Recent Comments