A colleague suddenly came to me, said he encountered a problem, in the call NHibernate update data when the error, said there is data row lock.
Look at the code, no problem.
It is not a problem to insert the database directly in the Pl/sql developer. There should be no transaction not committed, the table is locked. But we are low level, to prevent in case, or restart the database. After a hard reboot, try again, the problem is still, several times sunset red.
I later changed the update to insert and found that it was still wrong. Find the details of the error, prompting you to use a sequence called "seq_hibernate" (remember not very clearly). We have not defined this sequence, is this a sequence of nhibernate bands.
Look for it, find the entity class code here, the primary key ID does not define how to assign a value.
Generally, in NHibernate, entity class mappings, there are two ways to assign a value to an ID
Id (S => s.id). Generatedby.assigned (); Directly assigned value
Id (S => s.id). Generatedby.sequence ("Seq_website"); Using sequence
But that's what my colleague wrote:
Id (S => s.id);
There is no way to specify. Guessing is because the primary key ID is not assigned the assignment method, NHibernate the default method, using the default sequence Seq_hibernate (?) To produce a value for it. God knows that this seq_hibernate may be a lot of places in the request, so they reported a lock error.
The problem is resolved after the sequence is specified using the ID in a similar way.
Id (S => s.id). Generatedby.sequence ("Seq_website"); Using sequence