I have simple hibernate query with nolock used in query. I am getting error - A recognition error occurred and hibernate error is Exception thrown: 'NHibernate.Hql.Ast.ANTLR.QuerySyntaxException' in NHibernate.dll. it works without nolock. I don't want to use
<property name="connection.isolation">ReadUncommitted</property>
becasue I have to apply nolock to specific table only.
below is hql query -
select d from Users d with (nolock) where d.Userid = 2
Am I missing anything?
HQL will not support direct
with (nolock). But we can use native SQL query.So, for example, instead of something like this (getting list of users):
we would need to use raw sql API
In case, we know that by ID only one user will be returned.. we can use
UniqueResult<>instead of List