SQL Server pessimistic locking syntax incorrect for union-subclass
Description
Consider the class hierarchy Animal <- (Cat, Dog), mapped using the union-subclass, and the following query:
var query = session.CreateQuery("from Animal a where a.Name = ?"); query.SetLockMode("a", LockMode.Upgrade);
This code generates invalid SQL (using both 2000 and 2005 dialects) because the lock hints are inserted incorrectly. The SQL server error message states:
"Incorrect syntax near the keyword 'with'. If this statement is a common table expression or an xmlnamespaces clause, the previous statement must be terminated with a semicolon."
Consider the class hierarchy Animal <- (Cat, Dog), mapped using the union-subclass, and the following query:
var query = session.CreateQuery("from Animal a where a.Name = ?");
query.SetLockMode("a", LockMode.Upgrade);
This code generates invalid SQL (using both 2000 and 2005 dialects) because the lock hints are inserted incorrectly. The SQL server error message states:
"Incorrect syntax near the keyword 'with'. If this statement is a common table expression or an xmlnamespaces clause, the previous statement must be terminated with a semicolon."