【发布时间】:2013-07-09 19:49:48
【问题描述】:
我在休眠中有以下 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) 也能正常工作?
【问题讨论】:
-
这是 SQL 还是 HQL?如果是 SQL,您使用的是哪个数据库?