这里是HQL noob。如何在不使用exists子句的情况下重新编写此HQL查询。在SQL中,我可以加入VisitorProfileField表和Visitor表,并使用AND添加exists的条件。
但是在普通的HQL中,我猜不到一些语法违规。非常感谢您的帮助。
"select distinct v from Visitor v where v.id not in (select o.id from Operator o) " +
" and exists (select vpf from VisitorProfileField vpf " +
" where vpf.visitor = v and vpf.profileField.name = :subscription_field " +
" and vpf.numberVal = :type and vpf.stringVal = :manual) "
答案 0 :(得分:1)
我不确定我是否理解了您的查询,但我猜是这样的:
select distinct vpf.visitor
from VisitorProfileField vpf
where vpf.profileField.name = :subscription_field
and vpf.numberVal = :type and vpf.stringVal = :manual
and vpf.visitor.id not in (select o.id from Operator o)