执行选择没有锁的HQL?

时间:2014-03-24 09:34:46

标签: java sql-server hibernate hql

我有以下的hql查询。我想选择没有得到锁定表部门,员工让其他查询并发检索记录 即使以下查询正在运行/执行

,也可以从这些表中获取
from Department dept inner join fetch dept.employees  emp where dept.Id = :DeptId

我试过下面,但那仍然获得锁

from Department dept nolock inner join fetch dept.employees  emp nolock where dept.Id = :DeptId

1 个答案:

答案 0 :(得分:1)

from Department dept WITH(nolock) inner join fetch dept.employees  emp  where dept.Id = :DeptId

试试这个。 请注意FROM(nolock)附加到FROM子句。