I am trying to import some large files using batch queries and paralel processing and I’m constantly getting errors like
NHibernate.HibernateException: identifier of an instance of xxx was altered from ... to ...
I know I am not modifying my primary key at all. I am using NH 2.1.x GA, ThreadStaticSessionContext, every file is processed in a separate thread (using ThreadPool) and the information in the files is uncorelated. I do have a session and a transaction for each file, but I am not flushing the session at all. In the same thread I am commiting the transaction and closing the session but this error creeps me out.
If you have any suggestion…
Just to close this, I reckon the error occured because of poor coding skills (using shared resources spanning multiple threads without taking care on conccurency) and the identity over primary keys.
There was no place in code where I set or changed the primary key values by myself.