我在休眠中有以下 HQL 查询:
select x
from Item as x
where x not in (select o.item from Opinion as o where o.user =:user)
此查询工作正常,除非子查询 ( select o.item from Opinion as o where o.user =:user
) 返回一个空列表。在这种情况下,我得到了一个错误。
select o.item from Opinion as o where o.user =:user
当子查询( )为空时,有没有办法防止 Hibernate 引发错误?
我如何必须重写查询以使其即使对于空 ( select o.item from Opinion as o where o.user =:user
) 也能正常工作?